[postgis-devel] malloc/palloc/lwalloc

Mark Cave-Ayland mark.cave-ayland at siriusit.co.uk
Tue Sep 23 13:15:11 PDT 2008


Paul Ramsey wrote:
> I see that lwalloc traces back eventually palloc, and is there (?) to
> provide a means to compile and use liblwgeom separate from pgsql. I
> also see a few bare malloc calls, in the parser mostly, but also in
> lwgeom_geos_c.c and wonder if there's any reason not to corral those
> back into the pgsql process space?
> 
> p.

Okay. Given that there is probably little documentation on this, here is 
  how it works:

- Everything under liblwgeom/ should call lwalloc()/lwfree() if memory 
is required. These will then automatically map to either standard 
malloc()/free() in the case of a standalone build, or palloc()/pfree() 
in the case of a PostgreSQL build. There should be no standard 
malloc()/free() calls in there - if there is, they need to be replaced.

- Everything under lwgeom/ should call palloc()/pfree() since everything 
under this directory is only included in a PostgreSQL build.

Does that make sense?


ATB,

Mark.

-- 
Mark Cave-Ayland
Sirius Corporation - The Open Source Experts
http://www.siriusit.co.uk
T: +44 870 608 0063



More information about the postgis-devel mailing list