Re: Can I disable linking against the system malloc?
Re: Can I disable linking against the system malloc?
- Subject: Re: Can I disable linking against the system malloc?
- From: Jean-Daniel Dupas <email@hidden>
- Date: Tue, 5 Feb 2008 12:40:14 +0100
This will not override the system malloc, and call to strdup will
always returned a system allocated value.
The problem is that "electric fence" may use the system malloc under
the hood (for example in it's own malloc implementation).
So overriding the system malloc by the "electric fence" one may result
in a infinite loop, and a stack overflow.
If "electric fence" requires an 'electric fence' allocated string, it
should provide an strdup function, or you will have to implement one
using the "electric fence" malloc function.
Now, if you really really want to override the system malloc, it
possible to create a new memory zone (see <malloc/malloc.h>) and to
replace the default zone by your zone, but i don't think this is
recommanded (even if it works for pretty simple program).
Le 5 févr. 08 à 12:03, Steve Checkoway a écrit :
On Feb 4, 2008, at 9:25 PM, Terry Simons wrote:
This exercise is partly educational... I was just curious if it's
possible to force the system malloc to be ignored in my particular
situation.
I'm not totally sure why you'd want to do this, but this works for me:
#include <stdlib.h>
#include <assert.h>
void *malloc( size_t size ) { return NULL; }
int main()
{
void *p = malloc( 20 );
assert( p == NULL );
return 0;
}
--
Steve Checkoway
"Anyone who says that the solution is to educate the users
hasn't ever met an actual user." -- Bruce Schneier
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden