[Israel.pm] unreferenced scalar

Shmuel Fomberg semuelf at 012.net.il
Mon Sep 17 12:15:09 PDT 2007

Hello There.

I'm still playing with embedding Perl, and I wrote the following function:
void my_load_module(pTHX_ char *module_name) {
	SV *sv_name = newSVpv(module_name, 0);
	SV *sv_ver = newSViv(0);
	load_module(PERL_LOADMOD_NOIMPORT, sv_name, sv_ver);
//	SvREFCNT_dec(sv_name);
//	SvREFCNT_dec(sv_ver);

The idea is simple: declare two scalars, one containing the name of the
module to be loaded and the other the number '0'. (that's the minimum
version) pass these scalar to load_module, and in the end free the scalars.
Can anyone tell me why-o-why when I remove the two comments on the two
SvREFCNT_dec, I get two matching error messages:
Attempt to free unreferenced scalar: SV 0x0....

(the errors appear immidiatly after the executaion of these lines. Not in
the end of the program)


More information about the Perl mailing list