void call_it() {
......
SV* re = POPs;
Perl_sv_dump(my_perl,re);
SvREFCNT_inc(re);
......
}
int main(......) {
......
// calling the first time
printf("first time\n");
call_it();
// call again
printf("again\n");
call_it();
// call again
printf("and again\n");
call_it();
......
}
####
$ gcc -g -o test -I /usr/lib64/perl5/CORE -L /usr/lib64/perl5/CORE -lperl mini.c
$ ./test
going to return it: aaa
SV = PV(0xc43c78) at 0xc45d80
REFCNT = 1
FLAGS = (TEMP,POK,pPOK)
PV = 0xc5bde0 "aaa"\0
CUR = 3
LEN = 8
again
going to return it: aaa
SV = PV(0xc43df8) at 0xc45f60
REFCNT = 1
FLAGS = (TEMP,POK,pPOK)
PV = 0xc5c730 "aaa"\0
CUR = 3
LEN = 8
and again
going to return it: aaa
SV = PV(0xc43dc8) at 0xc612f8
REFCNT = 1
FLAGS = (TEMP,POK,pPOK)
PV = 0xc6a290 "aaa"\0
CUR = 3
LEN = 8
####
void call_it() {
......
SV* re = POPs;
Perl_sv_dump(my_perl,re);
......
}
####
$ gcc -g -o test -I /usr/lib64/perl5/CORE -L /usr/lib64/perl5/CORE -lperl mini.c
$ ./test
first time
going to return it: aaa
SV = PV(0x2001c78) at 0x2003d80
REFCNT = 1
FLAGS = (TEMP,POK,pPOK)
PV = 0x2019de0 "aaa"\0
CUR = 3
LEN = 8
again
going to return it: aaa
SV = PV(0x2001c78) at 0x2003d80
REFCNT = 1
FLAGS = (TEMP,POK,pPOK)
PV = 0x2019de0 "aaa"\0
CUR = 3
LEN = 8
and again
going to return it: aaa
SV = PV(0x2001c78) at 0x2003d80
REFCNT = 1
FLAGS = (TEMP,POK,pPOK)
PV = 0x2019de0 "aaa"\0
CUR = 3
LEN = 8