From: SourceForge.net <no...@so...> - 2012-03-12 17:52:06
|
Patches item #3486202, was opened at 2012-02-09 04:00 Message generated for change (Comment added) made by kwwette You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=301645&aid=3486202&group_id=1645 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None >Status: Closed >Resolution: Out of Date Priority: 5 Private: No Submitted By: Karl Wette (kwwette) Assigned to: William Fulton (wsfulton) Summary: Allow use of malloc() in C++ mode Initial Comment: I would like to be able to make SWIG use malloc() for memory allocation in typemaps (using %new_instance, et. al), even when compiling in C++ mode. The reason is basically that malloc() is easier to replace with a custom allocation function than new(). For example, if I have a custom string type that needs to be allocated using a custom allocation function, I can do something like: #define malloc MyStringMalloc %fragment("SWIG_FromMyStringPtrAndSize" ... %typemaps_string(...) #undef malloc and still re-use SWIG's typemaps for strings using MyStringMalloc() instead of malloc(). The attached one-line patch to Lib/typemaps/swigmacros.swg makes SWIG use new() for memory allocation only if the symbol SWIG_CPLUSPLUS_USE_MALLOC is not defined. This symbol can then be defined on the command line to make SWIG use malloc() instead. The default behaviour remains the same. ---------------------------------------------------------------------- >Comment By: Karl Wette (kwwette) Date: 2012-03-12 10:52 Message: I've found a much better way to do what I was trying to do, so have no further need for this patch ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=301645&aid=3486202&group_id=1645 |