diff options
Diffstat (limited to 'Modules/_struct.c')
-rw-r--r-- | Modules/_struct.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/Modules/_struct.c b/Modules/_struct.c index 0a09fd8..558d24b 100644 --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -1669,15 +1669,11 @@ PyDoc_STRVAR(s_sizeof__doc__, "S.__sizeof__() -> size of S in memory, in bytes"); static PyObject * -s_sizeof(PyStructObject *self) +s_sizeof(PyStructObject *self, void *unused) { Py_ssize_t size; - formatcode *code; - size = sizeof(PyStructObject) + sizeof(formatcode); - for (code = self->s_codes; code->fmtdef != NULL; code++) { - size += sizeof(formatcode); - } + size = sizeof(PyStructObject) + sizeof(formatcode) * (self->s_len + 1); return PyLong_FromSsize_t(size); } |