in reply to perlembed: reference counts

I don't know why, but it seems that load_module decreases the refcount of the sv_name argument (at least it does for me with perl 5.8.8/linux).

SV *sv_name = newSVpv("Carp", 0); warn("refbefore %d",SvREFCNT(sv_name)); load_module(PERL_LOADMOD_NOIMPORT, sv_name, Nullsv); warn("refafter %d",SvREFCNT(sv_name));
output:
refbefore 1 at .... refafter 0 at ....

Replies are listed 'Best First'.
Re^2: perlembed: reference counts
by semuel (Novice) on Sep 20, 2007 at 19:09 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...)

        Perl_newSVOP() takes a new reference to the passed-in SV but doesn't increment the ref count. Other places that remove this reference drop the ref count. Looks like an ordinary bug.

        - tye