This is the mail archive of the
newlib@sources.redhat.com
mailing list for the newlib project.
Re: user defined malloc
On Tue, Jul 04, 2000 at 04:49:00PM -0400, Ashif S. Harji wrote:
>On Tue, 4 Jul 2000, J. Johnston wrote:
>> > Basically, I am trying to find out if it is possible to provide my own
>> > version of malloc? If so, does this also require _malloc_r to be
>> > overriden (see message below?. And finally, if someone can provide some
>> > information or a link on what is required to override _malloc_r (if it is
>> > necessary).
>>
>> The _malloc_r routine is indeed a version of malloc which uses an additional
>> parameter to receive a reentrancy structure. The malloc routine simply calls _malloc_r with
>> the default reentrancy structure. Internally, any reentrant library routines must
>> call _malloc_r instead of malloc and pass whichever reentrancy structure was
>> passed to them. Thus, you want to replace the _r interfaces rather than the
>> top level routines like malloc() and free().
>>
>
>Thank you for the info. Presently it is not possible to override the
>_r interfaces, e.g. _malloc_r, with cygwin. I will pass along your
>message and request this change. Just for clarification, should I ask
>them to allow both the top level routines and the _r interfaces to be
>replaceable, or just the _r interfaces?
Cygwin exports the common versions of the 'malloc' family in the DLL. These
eventually translate into malloc_r, etc.
Overriding the _r family of functions would be tricky and probably would
require changing the startup code that is compiled into each application.
This is not something that I want to tackle but if someone provides a
patch I'll gladly consider it.
cgf