logo       

SWIG - Memory leak: msg#00176

programming.swig

Subject: SWIG - Memory leak

Mathieu Tremblay writes:
> Hi there, I have a problem with a very simple extended swig function.
> I'll try to make this as short as possible so here it is:
>
> In my C Code, I define the following:
> typedef float REAL32;
>
> I want to export a C function to swig that has the following prototype:
> void somefunction(REAL32 param1);
>
> Lets say my module is called : mymodule, in python I cant call write the
> following code:
> import mymodule
> mymodule.somefunction(1.0)
> because it is telling me that I pass the wrong argument type. So I
> created a simple typecasting function that maps a float to a REAL32,
> even if it is casting to the same type (float = REAL32),
>

Did you tell SWIG about the typedef? There should be no need to
write special functions, converters, or anything like that to make
this work.
>
> Is it because I do something wrong? Is there another way of doing this ?
>

It's leaking memory because you didn't tell SWIG what a REAL32 is (the
typedef).

See

http://www.swig.org/Doc1.3/SWIG.html#n19
http://www.swig.org/Doc1.3/SWIG.html#n23

-- Dave
_______________________________________________
Swig maillist - Swig@xxxxxxxxxxxxxxx
http://mailman.cs.uchicago.edu/mailman/listinfo/swig



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise