summaryrefslogtreecommitdiff
path: root/c/ffi_obj.c
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2016-10-28 00:05:25 +0200
committerArmin Rigo <arigo@tunes.org>2016-10-28 00:05:25 +0200
commitb66d371af0e90e93fc0d0d56a5a3e2ff76ff9610 (patch)
tree98ef298c2dc4df78462baa0de5082645e87166f8 /c/ffi_obj.c
parentdcfbf4bf975e66029e6ef00ce36395c75c2f3ee7 (diff)
downloadcffi-b66d371af0e90e93fc0d0d56a5a3e2ff76ff9610.tar.gz
One more case, this time in CompiledFFI.sizeof().
Diffstat (limited to 'c/ffi_obj.c')
-rw-r--r--c/ffi_obj.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/c/ffi_obj.c b/c/ffi_obj.c
index aad59fc..3c4866e 100644
--- a/c/ffi_obj.c
+++ b/c/ffi_obj.c
@@ -257,22 +257,20 @@ PyDoc_STRVAR(ffi_sizeof_doc,
static PyObject *ffi_sizeof(FFIObject *self, PyObject *arg)
{
Py_ssize_t size;
- CTypeDescrObject *ct = _ffi_type(self, arg, ACCEPT_ALL);
- if (ct == NULL)
- return NULL;
-
- size = ct->ct_size;
if (CData_Check(arg)) {
- CDataObject *cd = (CDataObject *)arg;
- if (cd->c_type->ct_flags & CT_ARRAY)
- size = get_array_length(cd) * cd->c_type->ct_itemdescr->ct_size;
+ size = direct_sizeof_cdata((CDataObject *)arg);
}
-
- if (size < 0) {
- PyErr_Format(FFIError, "don't know the size of ctype '%s'",
- ct->ct_name);
- return NULL;
+ else {
+ CTypeDescrObject *ct = _ffi_type(self, arg, ACCEPT_ALL);
+ if (ct == NULL)
+ return NULL;
+ size = ct->ct_size;
+ if (size < 0) {
+ PyErr_Format(FFIError, "don't know the size of ctype '%s'",
+ ct->ct_name);
+ return NULL;
+ }
}
return PyInt_FromSsize_t(size);
}