On Monday, September 2, 2002, at 06:41 PM, Neil Watkiss wrote:

> Hi Ken,
>
> You shouldn't mix this:
>
>>    soldier->name = strdup(name);
>
> with this:
>
>>    Safefree(soldier->name);
>
> because strdup() is just a C library function that uses malloc(), and
> Safefree might not be. You want to use savepv(), which is the 
> Perl API's
> equivalent that's guaranteed to work with Safefree.
>
> Have a look at 'perldoc perlapi' for more info.
>


Wow, I'd never have known that from `perldoc perlapi`.  I had to 
look at `perldoc perlclib`, which I'd never even *heard* of 
before, and which I'd never have found without `grep savepv 
/usr/share/man/man1/perl*`.

I'll be changing this in my own code now too.  Thanks for the pointer.

  -Ken

Reply via email to