apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Graham Leggett <minf...@sharp.fm>
Subject Re: custom memory allocators ?
Date Wed, 12 Mar 2008 19:07:14 GMT
Adrian Stan wrote:

> Pool based allocation is good for some class of applications indeed, but 
> the library should be flexible enough to allow the user to specify his 
> own memory allocation scheme (or not to use one at all and to directly 
> allocate memory on the heap using malloc)

I've never tried this, but would it not be enough to create a pool, use 
the pool, and then destroy the pool directly afterwards if necessary?

The existence of pools significantly simplifies a lot of APR, because 
you no longer need to keep track of whether a buffer you have been given 
needs to be freed or not.

As a result, if a function needs to return a static string (for 
argument's sake), it will just return the static string, instead of 
returning a malloc'ed copy of the static string so that when the caller 
calls free it will always work.


View raw message