There is a function that at one point does:typedef struct { ... char *line ; ... } parse_data ; parse_data pd ;
What I want to do later is return the string that I have stored, and free up the memory. The following is one example of how I have tried to do it:pd.line = strdup(s) ;
The problem is with the call to free. If this is included, perl core dumps. The strack trace looks like this:void get_line () PPCODE: EXTEND(SP, 1) ; PUSHs (sv_2mortal(newSVpv(pd.line,0))) ; free (pd.line) ; pd.line = 0 ;
Moving the call to free to just before where I reassign a new line works, but after the last call, I would end up with a chunk of unfreed memory hanging around. I *thought* that newSVpv allocated the memory to store the string in, and then copied in my string. If it doesn't, and just runs down the pointer I gave it, then it will of course blow up. How can I pass the value out to Perl and not leave allocated memory hanging about? Yours banging head against wall, Nosmoemergency_sbrk(blah) morecore(blah) Perl_sv_grow(blah) Perl_sv_catpvn(blah) Perl_pp_concat(blah) Perl_runops_standard(blah)
In reply to Help with Perl Extension by nosmo_1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |