semuel has asked for the wisdom of the Perl Monks concerning the following question:

Hello.

I am writing a program in C that embeds Perl. one of my functions does this:

void my_load_module(pTHX_ const char *module_name) { SV *sv_name = newSVpv(module_name, 0); load_module(PERL_LOADMOD_NOIMPORT, sv_name, Nullsv); // SvREFCNT_dec(sv_name); }
The problem is, if I uncomment the last line, I get en error saying the I try to decresed a ref_count of zero.
or, in Perl's own words:
Attempt to free unreferenced scalar: SV 0x0....
why?
Shmuel.

Replies are listed 'Best First'.
Re: perlembed: reference counts
by Joost (Canon) on Sep 19, 2007 at 22:08 UTC
      The question is, of course, why.
      I am looking for documentation, comment or even a pointer to the source code will be enough.
      (I looked for that function in the source code, and for some reason could not find it...)