Re: emalloc() - odd result
| From: | Rasmus Lerdorf | Date: | Thu, 01 Jan 1970 00:00:00 +0000 |
| Subject: | Re: emalloc() - odd result | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-3826@lists.php.net to get a copy of this message | ||
[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.
-Rasmus
--
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