Re: Re: emalloc() - odd result

From: Date: Tue, 02 Feb 1999 23:30:41 +0000
Subject: Re: Re: emalloc() - odd result
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-3827@lists.php.net to get a copy of this message
At 11:58 01/02/99 -0500, Rasmus Lerdorf wrote: >[cc'ed to the php-dev list] > >> We are in the process of converting some of our scripts to a php module. We >> are using the emalloc() and we are getting some odd results. >> >> Is there a minimum number of bytes to allocate with emalloc() ? >> >> We ar calling the function a number (>250 times) of times with size = 20, >> and and for one reason or another we ar getting a pointer to a memory block >> of 16 bytes and when we try to write 20 bytes we overwrite another memory >> block witch contains a pointer to another structure. If we try to increase >> the memory size allocated with emalloc to 20+128 bytes the error moves to >> another part of the code. >> >> This might be a problem with malloc on Win32 ? >> >> If emalloc() requires a minimum size is it possible to test for this size >> inside emalloc() ? > >There should not be a minimum size. The only thing I can think of is that >PLATFORM_PADDING is screwy for some reason on Win32. But, I would have >expected this to have bitten us ages ago if this was true. > >Have a look at the _emalloc() function in alloc.c. It doesn't do anything >very fancy. Keeps a linked list of memory blocks and hands back an >aligned address. The checks should be ok. The platform padding isn't screwy, the memory manager with the magic numbers would have gone crazy if it was, but it works fine. I'd guess the error is someplace else, not the memory manager. I'd have to see the code to actually back that assumption up, though. Zeev -- Zeev Suraski <zeev@zend.com> http://www.zend.com/ For a PGP public key, finger bourbon@netvision.net.il -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#3827) next »