Author: Andrew Leech <and...@alelec.net> Branch: new_struct_allocated_size Changeset: r2786:8e7211a884bd Date: 2016-09-12 14:02 +1000 http://bitbucket.org/cffi/cffi/changeset/8e7211a884bd/
Log: Add length field to CDataObject_own_structptr to hold the size of the memory block allocated for the struct. This is particularly useful for C99 variable-sized structures where the sizeof(<typedef>) does not directly inform the allocated size. diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c --- a/c/_cffi_backend.c +++ b/c/_cffi_backend.c @@ -238,6 +238,7 @@ typedef struct { CDataObject head; + Py_ssize_t length; /* same as CDataObject_own_length up to here */ PyObject *structobj; } CDataObject_own_structptr; @@ -3199,6 +3200,7 @@ } /* store the only reference to cds into cd */ ((CDataObject_own_structptr *)cd)->structobj = (PyObject *)cds; + ((CDataObject_own_structptr *)cd)->length = datasize; assert(explicitlength < 0); cd->c_data = cds->c_data; _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit