Perl: the Markov chain saw | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I decided to make a little test to see what malloc() is doing
I pretty much always use "Newx" or "Newxz" instead of "malloc" because I read somewhere that they are the recommended XS way of allocating memory. However, I've always found the 2 alternatives to be interchangeable. Maybe there are some systems and/or perl configurations where they cannot be used interchangeably but, to my knowledge, I've not encountered such a case. IME, doing Newx(x, 42, datatype) is effectively the same as doing x=malloc(42 * sizeof(datatype)). The important difference is that the former allocation must be released by "Safefree", whereas the latter must be released by "free". Therein lies the sum of my knowledge of memory allocation ;-) Cheers, Rob In reply to Re^8: Perl XS binding to a struct with an array of chars*
by syphilis
|
|