SourceForge.net | 9 Feb 13:00
Picon

[ swig-Patches-3486202 ] Allow use of malloc() in C++ mode

Patches item #3486202, was opened at 2012-02-09 04:00
Message generated for change (Tracker Item Submitted) 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: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Karl Wette (kwwette)
Assigned to: Nobody/Anonymous (nobody)
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().
(Continue reading)

SourceForge.net | 9 Feb 13:00
Picon

[ swig-Patches-3486202 ] Allow use of malloc() in C++ mode

Patches item #3486202, was opened at 2012-02-09 04:00
Message generated for change (Settings changed) 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: Open
Resolution: None
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().
(Continue reading)


Gmane