in reply to a tale of the windows runtime libs
As anonymonk points out, XS code is meant to use New*() and Safefree(). In part, to avoid the predictable problems with multiple runtimes trying to manage heap memory. However, I find these PerlAPI functions inconvenient to use because of their non-standard calling syntax (a problem rife throughout the PerlAPI).
It means that you cannot initialise pointers in-line with their declarations. So, like many others, I've wrapped those APis in more convenient and intuative wrappers
void *Calloc( int n, int size ) { void *p; Newxz( p, n * size, char ); return p; } void Free( void *p ) { Safefree( p ); }
Note the uppercase first chars. Done to avoid conflicts with the dozens of other definitions and re-definitions of calloc() and free() (along with malloc() et al.) spread throughout the Perl sources.
|
|---|