On 7/29/2004 5:16 PM, Williams, Kenneth (Ken) (TLR Corp) wrote:
Hi,

Suppose I'm writing some Inline C code that calls out to an external C library. I call a function that allocates some memory internally using malloc(), and hands a struct back to me. When I want to free that memory again, should I use free(), or Safefree()? 'perldoc perlclib' doesn't give a very clear answer on this matter.

If the external library doesn't provide a function to free the memory, you'll need to use the C runtime free() call. Perl's memory allocation routines are not guaranteed to operate on the same memory pool, i.e. you could end up freeing memory from the wrong pool or worse, freeing memory from the wrong pool that is being used.


Randy.



Reply via email to