Re: Changing default alloc routines in C
Mayank Chaudhary <[email protected]> Mon, 9 Jan 2023 15:39:39 +0530
| Newsgroups | gmane.comp.programming.swig |
|---|---|
| Message-ID | <CAAKn+iDdTD36ucubQkh-ec5i28TrX=KHcdLhDOgyR9r-ocKZrQ@mail.gmail.com> |
Thanks for your response Burlen but in our case we want to replace malloc and calloc in _wrap file which is generated by swig using interface file. The custom calloc func should take size of the memory and also the string which says the type of the structure..So that it will be useful in memory tracking…and it will be useful in debugging memory leak even if the process crashed. Is there a way to do this change using swig? Thanks, Mayank On Thu, Dec 29, 2022 at 1:36 AM Burlen Loring <[email protected]> wrote: > Yes. GNU has some documentation about how you replace malloc. > https://www.gnu.org/software/libc/manual/html_node/Replacing-malloc.html > > > > On 12/14/22 21:25, Mayank Chaudhary wrote: > > Hi, I'm new to swig and am generating C wrappers using it. > > Swig uses default malloc and calloc functions for memory allocations while > generating wrappers. Is there any way where I can specify a custom > allocation function in the interface file and use that instead of malloc > and calloc? > > *For example - something like my_malloc, my_calloc and my_free or any > custom func(I have defined these functions in a separate file) to be used > everywhere instead of malloc, calloc and free* > > I tried typemaps and renaming functions but that didn't work. > > Requesting your support. > > Thanks & Regards, > Mayank > > > _______________________________________________ > Swig-user mailing [email protected]://lists.sourceforge.net/lists/listinfo/swig-user > > > _______________________________________________ Swig-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/swig-user