| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f7c01a1 commit e294757
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4354,10 +4354,10 @@ _init_pos_args(PyObject *self, PyTypeObject *type, | |||
| 4354 | 4354 | return index; | |
| 4355 | 4355 | } | |
| 4356 | 4356 | ||
| 4357 | - for (i = 0; | ||
| 4358 | - i < dict->length && (i+index) < PyTuple_GET_SIZE(args); | ||
| 4357 | + for (i = index; | ||
| 4358 | + i < dict->length && i < PyTuple_GET_SIZE(args); | ||
| 4359 | 4359 | ++i) { | |
| 4360 | - PyObject *pair = PySequence_GetItem(fields, i); | ||
| 4360 | + PyObject *pair = PySequence_GetItem(fields, i - index); | ||
| 4361 | 4361 | PyObject *name, *val; | |
| 4362 | 4362 | int res; | |
| 4363 | 4363 | if (!pair) | |
@@ -4367,7 +4367,7 @@ _init_pos_args(PyObject *self, PyTypeObject *type, | |||
| 4367 | 4367 | Py_DECREF(pair); | |
| 4368 | 4368 | return -1; | |
| 4369 | 4369 | } | |
| 4370 | - val = PyTuple_GET_ITEM(args, i + index); | ||
| 4370 | + val = PyTuple_GET_ITEM(args, i); | ||
| 4371 | 4371 | if (kwds) { | |
| 4372 | 4372 | res = PyDict_Contains(kwds, name); | |
| 4373 | 4373 | if (res != 0) { | |
@@ -4388,7 +4388,7 @@ _init_pos_args(PyObject *self, PyTypeObject *type, | |||
| 4388 | 4388 | if (res == -1) | |
| 4389 | 4389 | return -1; | |
| 4390 | 4390 | } | |
| 4391 | - return index + dict->length; | ||
| 4391 | + return dict->length; | ||
| 4392 | 4392 | } | |
| 4393 | 4393 | ||
| 4394 | 4394 | static int | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -119,14 +119,7 @@ PyCStgDict_clone(StgDictObject *dst, StgDictObject *src) | |||
| 119 | 119 | ||
| 120 | 120 | if (src->ffi_type_pointer.elements == NULL) | |
| 121 | 121 | return 0; | |
| 122 | - /* src->ffi_type_pointer.elements is an */ | ||
| 123 | - /* array of pointers to ffi_type that */ | ||
| 124 | - /* contains a trailing NULL pointer. */ | ||
| 125 | - /* src->size is the size of the array */ | ||
| 126 | - /* in bytes excluding the trailing NULL */ | ||
| 127 | - /* pointer, so we have to add it in to */ | ||
| 128 | - /* to compute how many bytes to copy. */ | ||
| 129 | - size = src->size + max(sizeof(ffi_type *), src->align); | ||
| 122 | + size = sizeof(ffi_type *) * (src->length + 1); | ||
| 130 | 123 | dst->ffi_type_pointer.elements = PyMem_Malloc(size); | |
| 131 | 124 | if (dst->ffi_type_pointer.elements == NULL) { | |
| 132 | 125 | PyErr_NoMemory(); | |
@@ -380,7 +373,7 @@ int | |||
| 380 | 373 | PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct) | |
| 381 | 374 | { | |
| 382 | 375 | StgDictObject *stgdict, *basedict; | |
| 383 | - Py_ssize_t len, offset, size, align, i, base_len; | ||
| 376 | + Py_ssize_t len, offset, size, align, i; | ||
| 384 | 377 | Py_ssize_t union_size, total_align, aligned_size; | |
| 385 | 378 | Py_ssize_t field_size = 0; | |
| 386 | 379 | int bitofs; | |
@@ -472,22 +465,19 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct | |||
| 472 | 465 | union_size = 0; | |
| 473 | 466 | total_align = align ? align : 1; | |
| 474 | 467 | stgdict->ffi_type_pointer.type = FFI_TYPE_STRUCT; | |
| 475 | - /* calculate the cumulative number of elements in the base class */ | ||
| 476 | - /* so that all elements get copied to the child class */ | ||
| 477 | - base_len = size / max(sizeof(ffi_type *), align); | ||
| 478 | - stgdict->ffi_type_pointer.elements = PyMem_New(ffi_type *, base_len + len + 1); | ||
| 468 | + stgdict->ffi_type_pointer.elements = PyMem_New(ffi_type *, basedict->length + len + 1); | ||
| 479 | 469 | if (stgdict->ffi_type_pointer.elements == NULL) { | |
| 480 | 470 | PyErr_NoMemory(); | |
| 481 | 471 | return -1; | |
| 482 | 472 | } | |
| 483 | 473 | memset(stgdict->ffi_type_pointer.elements, 0, | |
| 484 | - sizeof(ffi_type *) * (base_len + len + 1)); | ||
| 485 | - if (size > 0) { | ||
| 474 | + sizeof(ffi_type *) * (basedict->length + len + 1)); | ||
| 475 | + if (basedict->length > 0) { | ||
| 486 | 476 | memcpy(stgdict->ffi_type_pointer.elements, | |
| 487 | 477 | basedict->ffi_type_pointer.elements, | |
| 488 | - size); | ||
| 478 | + sizeof(ffi_type *) * (basedict->length)); | ||
| 489 | 479 | } | |
| 490 | - ffi_ofs = base_len; /* index of the child class's first element */ | ||
| 480 | + ffi_ofs = basedict->length; | ||
| 491 | 481 | } else { | |
| 492 | 482 | offset = 0; | |
| 493 | 483 | size = 0; | |
@@ -705,7 +695,7 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct | |||
| 705 | 695 | ||
| 706 | 696 | stgdict->size = aligned_size; | |
| 707 | 697 | stgdict->align = total_align; | |
| 708 | - stgdict->length = len; /* the number of elements in the child class */ | ||
| 698 | + stgdict->length = ffi_ofs + len; | ||
| 709 | 699 | ||
| 710 | 700 | /* | |
| 711 | 701 | * The value of MAX_STRUCT_SIZE depends on the platform Python is running on. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments