How to allocate and de-allocate memory for CFFI structure

Joined
Apr 15, 2016
Messages
1
Reaction score
0
typedefstruct user{
unsignedlong id;
char*name;
struct1 type;
intPeriod;
char*altername;
char*description;
struct2 state;
struct3 *userDetails;
}CUser;

typedefstruct_CDeltaUser
{
CUser*deltaUser;
struct3 *deletedUserDetails;
struct3 *changedUserValues;}CDeltaUser;
I am trying to create a object for this structure through CFFI and assign the values for the members and pass the created object to a API in C++.

deltaUser = ffi.new("CDeltaUser*")

deltaUser.deltaUser = ffi.new("CUser*")

deltaUser.deltaUser.id=4
Now when i try to pass this deltaUser to an API in C++ through the dll loaded using ffi.dlopenApiName(par1,par2,deltaUser,par4) python crashes at this point. crash occurs both in windows and Linux.

What is wrong with this code ? I am using python2.7 and cffi 1.5.2

on traceback gives the following log. Found that value is optimised

in ffi_call (cif=0x7ffff1189260, fn=0x7ffff0488faa , rvalue=0x7ffff118e098, avalue=0x7ffff118e078) at src/x86/ffi64.c:484 in cdata_call (cd=0x7ffff118c0d0, args=0x7ffff7ee4310, kwds=) at c/_cffi_backend.c:2637 in PyObject_Call (func=0x7ffff118c0d0, arg=, kw=) at Objects/abstract.c:2529 in do_call (f=, throwflag=) at Python/ceval.c:4239 call_function (f=, throwflag=) at Python/ceval.c:4044

Thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top