line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
/* vi: set ft=c : */ |
2
|
|
|
|
|
|
|
|
3
|
0
|
|
|
|
|
|
static int magic_free(pTHX_ SV *sv, MAGIC *mg) |
4
|
|
|
|
|
|
|
{ |
5
|
0
|
|
|
|
|
|
void (*freefunc)(pTHX_ SV *sv) = (void *)mg->mg_ptr; |
6
|
0
|
|
|
|
|
|
(*freefunc)(aTHX_ sv); |
7
|
0
|
|
|
|
|
|
return 0; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
static const MGVTBL vtbl_sv_with_free = { |
11
|
|
|
|
|
|
|
.svt_free = magic_free, |
12
|
|
|
|
|
|
|
}; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
#define newSV_with_free(size, freefunc) S_newSV_with_free(aTHX_ size, freefunc) |
15
|
0
|
|
|
|
|
|
static SV *S_newSV_with_free(pTHX_ STRLEN size, void (*freefunc)(pTHX_ SV *sv)) |
16
|
|
|
|
|
|
|
{ |
17
|
0
|
|
|
|
|
|
SV *sv = newSV(size); |
18
|
0
|
|
|
|
|
|
sv_magicext(sv, NULL, PERL_MAGIC_ext, &vtbl_sv_with_free, (void *)freefunc, 0); |
19
|
0
|
|
|
|
|
|
return sv; |
20
|
|
|
|
|
|
|
} |