I am completely new to Perl XS.
My simple test function gets a string and adds something. Perl has a scalar string in and one.
In the function, I have malloc. What is the right way to free up memory?
SV *foo (str) SV *str CODE: unsigned char *strbuf; size_t strlen; strbuf = (unsigned char *) SvPV (str, strlen); int n = strlen + 10; unsigned char *buf = malloc (n); strncpy (buf, strbuf, strlen); strncat (buf, "0123456789", 10); RETVAL = newSVpv (buf, n); OUTPUT: RETVAL
thanks! Chris
source share