I think you leaked ST(0)
I added a wrapping of PL_sv_count to the Inline::C script:
void wrap_count() {
printf("wrap_count: %d\n", PL_sv_count);
}
If I call wrap_count() after each call to call_Adder() I find that the count has remained the same. I *think* that means that no leaking has occurred.
Also, if I
sv_2mortal(ST(0)); before returning ST(0) I get the "Attempt to free unreferenced scalar" warning again.
I dont omit the ENTER/LEAVE since I don't have a good understanding when its safe to omit ENTER/LEAVE
Turns out I can put them in without the script suffering any adverse effect, so I think I might do that. I could also re-instate SAVETMPS/FREETMPS if necessary, but I'll leave them out for now. (All 4 caused me some grief in my earlier attempts to get this script working, so I removed them and didn't get around to checking whether they did, in fact, really *need* to be removed.)
I'm not sure if the count check makes senseYes, it's something I've just copied verbatim from the perlcall examples, without any appreciation of it's siginificance. The error message is "Big trouble", which would be a very appropriate message if G_SCALAR is supposed to force the count as you say ;-)
Thanks for the feedback.
Please let me know if I'm still missing something.
Cheers,
Rob
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.