Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: Perl XS: garbage-collecting my malloc'd bufferby pg (Canon) |
on Mar 03, 2003 at 16:37 UTC ( [id://240068]=note: print w/replies, xml ) | Need Help?? |
Not about Perl, but for the c code, it is better to check whether tmp_buffer is NULL, after the malloc call. If it is NULL, then the malloc failed, and there is no point to continue, otherwise you would see core dumps somewhere down the road. It is also better to check whether it is a NULL pointer, before you free it. (As this is demo, I guess you might have the checking in your real code ;-), just in case…)
In Section
Seekers of Perl Wisdom
|
|