Re: How to add code to a C wrapper function generated by SWIG (for Python)
Rokas Kupstys via Swig-user <[email protected]> Fri, 22 Jan 2021 11:59:55 +0200
| Newsgroups | gmane.comp.programming.swig |
|---|---|
| Message-ID | <[email protected]> |
Maybe %newobject + %newfree typemaps would work for you in this case?
-- Rokas Kupstys
On 2021-01-22 10:48, lille stor wrote:
>
> Hi,
>
> When generating a Python wrapper using SWIG, many C wrapper functions
> are generated. One of them is called "|_wrap_delete_Cursor" which
> looks like this| (I have stripped it to the bare minimum):
>
> |SWIGINTERN PyObject *_wrap_delete_Cursor(PyObject *self, PyObject
> *args) { // some generated C code by SWIG // need to add code to
> call a C function to release allocated memory } |
>
> This function is called when the object Cursor (created in Python) no
> longer exists. Now, my problem is that I have some allocated memory on
> the C side that needs to be released before existing the function
> (otherwise, there will be memory leaks).
>
> Do you know how I can add a line of code this function to release
> memory? All help is really welcome!
>
> L.
>
>
>
> _______________________________________________
> Swig-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/swig-user
_______________________________________________
Swig-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/swig-user