in reply to General memory management for embedded/extended perl with C threads
Then you also need to provide, in the same source file:char* my_crappy_strdup( const char* str ) { char* s = malloc(strlen(str)+1); memcpy( s, str, strlen(str)+1 ); return s; }
And make sure that the caller of my_crappy_strdup() knows that they need to call my_crappy_free() on whatever data is created. Then it doesn't matter if that C library is using perl's memory manager, ElectricFence, libc, or whatever. One of the interesting consequences of this, by the way, is that it's basically impossible to use libc's strdup() in perl extensions without some nasty #define magic because you'll never be able to get at the libc free() call... c.void my_crappy_free( char* str ) { free(s); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: General memory management for embedded/extended perl with C threads
by Anonymous Monk on Nov 15, 2004 at 12:47 UTC |