Given the header file:
struct SCIP {}; void SCIPcreate(struct SCIP **s) { *s = malloc(sizeof **s); }
We can wrap this function using:
%module test %{ #include "test.h" %} %typemap(in,numinputs=0) struct SCIP **s (struct SCIP *temp) { $1 = &temp; } %typemap(argout) struct SCIP **s { %set_output(SWIG_NewPointerObj(SWIG_as_voidptr(*$1), $*1_descriptor, SWIG_POINTER_OWN)); } %include "test.h"
which consists of two typical forms: one to create a local temporary pointer that will be used as input for the function, and the other to copy the value of the pointer after the call to return.
Alternatively, you can also use %inline to set the overload:
%newobject SCIPcreate; %inline %{ struct SCIP *SCIPcreate() { struct SICP *temp; SCIPcreate(&temp); return temp; } %}
Flexo source share