seg violation using pycapsule_new
- by user1733051
I am trying some simple c API, where I am using PyCapsule_New to encapsulate a pointer. I am running into segment violation, can some body help me.
mystruct *func1(int streamno, char mode,unsigned int options)
{
char * s;
s=malloc(100);
return s;
}
PyObject *Wrapper_func1(PyObject *self, PyObject *args)
{
int streamno;
char mode;
unsigned int options;
mystruct* result;
if (!PyArg_ParseTuple(args,"icI",&streamno,&mode,&options))
return NULL;
result = func1(streamno,mode,options);
return PyCapsule_New( result,NULL,NULL);
}