Yeah, XS is extremely difficult to do correctly. I don't see where your code causes a leak (not surprising, since this is usually quite complicated to figure out). So you would be wise to minimize the amount of XS code you write. For example, have a Perl wrapper that uses a simple pack and unpack and eliminate almost all of the "manipulate Perl internal data structure" stuff from your XS:
char * top_insert( up, down, init_step_ratio, ratio ) char * up char * down double init_step_ratio double ratio INIT: int up_num, down_num, sample_num; double *return_val = NULL; PPCODE: up_num = {length of arg 0}/sizeof(double)/3; down_num = {length of arg 1}/sizeof(double)/3; return_val = get_inter_line( up_num, (double*)up, down_num, (double*)down, init_step_ratio, ratio, &sample_num ); sample_num *= 3; {set return value SV to: copy of return_val w/ length sample_num*sizeof(double)} del_inter_line(return_val);
(The few bits of dealing with Perl internal data structures left as an exercise above as I don't have those memorized.)
- tye
In reply to Re: xs memoryleak (xs--)
by tye
in thread xs memoryleak
by yarp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |