Hi,

Relevant lines from an inline C function that is called reiteratively:
-----------------------------
double *w; /* the declaration */
 w = (double *)calloc(len * 2, sizeof(double));
free(w);
-----------------------------

(Aside: Is that cast operation prior to the 'calloc' call necessary? I don't
understand its role, given that I've declared 'double *w'. Under what
circumstances do I need to cast ?).

Well ..... it works ok for a few iterations, but then crashes on 'free(w)'.
Then I found that 'free' is one of the 'don't use' functions listed in
'symbols.perl', mentioned in the Inline C documentation .... so I guess that
is the source of the problem.

Also found one of Sam Tregar's posts recommending use of 'New()' and
'Safefree()', so I looked 'em up in perlapi ... but I still can't equate the
prototypical syntax given there, to the syntax that I need to employ in my
script.

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)

Seems to me that there's more parameters than necessary. (I know that's
*not* the case.) eg. I expected that 'Safefree(w)' would be sufficient in my
script :-)

Cheers,
Rob

Reply via email to