On 28/05/02 13:07 +1000, Sisyphus wrote:
> -----------------------------
> double *w; /* the declaration */
> w = (double *)calloc(len * 2, sizeof(double));
> free(w);
> -----------------------------
> Someone mind spelling out how I use 'New()' and 'Safefree()', for me ?
>
> Here's what perlapi provides about them:
> void New(int id, void* ptr, int nitems, type)
> void Safefree(void* src, void* dest, int nitems, type)
I'm definitely no expert here, but...
I just did a quick 'grep -r' though the Perl source tree. Every single
usage of Safefree takes exactly one argument. I'm not sure where the
manpage is coming from.
As for New (and Newz) it definitely takes 4 arguments. The first seems
to be some arbitrary integer. I think it may be used for debugging, but
I'm not sure here. Neil? The second argument is a pointer variable. The
third is the number of units to allocate. The fourth is simply the type
of the second argument. I guess the total bytes allocated == third arg *
sizeof(fourth arg).
So:
foo_t *foo;
New(193, foo, 42, foo_t);
Safefree(foo);
Hope that helps.
Cheers, Brian