Question about malloc / realloc in module

2011-09-14 Thread Christoph Gröver
Hello list, In a module I have to allocate and reallocate a chunk of memory. Because (AFAIK) Apache or its libraries do not support reallocation I use the standard functions malloc/realloc (and free), of course. But what if there's a problem in another module? Is it possible that due to some

Re: Question about malloc / realloc in module

2011-09-14 Thread Joshua Marantz
If you malloc/calloc/realloc without a free you will leak memory. Do you have some reason to believe that another module might prevent your module's calls to free() from being run? What do you have in mind specifically? You can also mimic realloc by just allocating more memory from the pool and

Re: Question about malloc / realloc in module

2011-09-14 Thread Nick Kew
On Wed, 14 Sep 2011 14:01:19 +0200 Christoph Gröver gro...@sitepark.com wrote: So would this result in a memory leak? (if this happens often!) Potentially yes, unless you can do an exhaustive analysis of all possible processing paths. The fix for that is to register a free as a pool cleanup

Re: Question about malloc / realloc in module

2011-09-14 Thread Christoph Gröver
Thank you, Nick, for your answer, So would this result in a memory leak? (if this happens often!) Potentially yes, unless you can do an exhaustive analysis of all possible processing paths. The fix for that is to register a free as a pool cleanup immediately after the malloc/realloc.

Re: Question about malloc / realloc in module

2011-09-14 Thread Eric Covener
But what if a process exists in a faulty way. Perhaps some PHP code that exists abnormally? If the process exits, you've got no worries about memory. If a thread hangs [indefinitely], before you can free memory, the memory is probably the least of your problems.