Skip to content

Instantly share code, notes, and snippets.

@ivpusic
Last active December 19, 2015 04:48
Show Gist options
  • Save ivpusic/5899342 to your computer and use it in GitHub Desktop.
Save ivpusic/5899342 to your computer and use it in GitHub Desktop.
# case 1
cdef:
ffi_type *f_type
ffi_type* elements[3]
if (some condition......):
some code........
else:
# THIS WORKS #
f_type.size = 0
f_type.alignment = 0
f_type.type = FFI_TYPE_STRUCT
f_type.elements = elements
elements[0] = &ffi_type_uint64
elements[1] = &ffi_type_uint64
elements[2] = NULL
self.f_result_type = &f_type
#########################################################
# case 2
cdef void _resolve_complex_ffi_type(self):
cdef:
ffi_type *f_type
ffi_type* elements[3]
self.f_result_type = <ffi_type*>malloc(sizeof(ffi_type))
f_type = <ffi_type*>malloc(sizeof(ffi_type))
f_type.size = 0
f_type.alignment = 0
f_type.type = FFI_TYPE_STRUCT
f_type.elements = elements
elements[0] = &ffi_type_uint64
elements[1] = &ffi_type_uint64
elements[2] = NULL
self.f_result_type = f_type
.
.
.
.
if (some condition......):
some code........
else:
# THIS DOES NOT WORK #
self._resolve_complex_ffi_type()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment