in reply to eval_pv leaking
eval_pv Tells Perl to "eval" the given string and return an SV* result.
I tried usingbut that didn't work (probably because eval_pv works "kindof like a subroutine" in that it returns a mortal SV* - or something; I confess ignorance of the subtleties in perlembedding) - so messed around with the code until I came up with this:SV* ret = eval_pv("1;", TRUE); SvREFCNT_dec(ret);
for (;;) { ENTER; SAVETMPS; SV* ret = eval_pv("1;", TRUE); FREETMPS; LEAVE; }
Which doesn't leak for me (perl, v5.8.5 built for i686-linux-thread-multi).
update: this is not really documented AFAIK, probably because you're not likely to be calling eval_* all that much. The perlembed documentation should probably mention something about how to deal with the return value (as it does describe handling the various call_* parameters and return values).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: eval_pv leaking
by PreferredUserName (Pilgrim) on Dec 27, 2004 at 19:40 UTC |