int i;
list = PerlIO_list_alloc(aTHX);
for (i=0; i < proto->cur; i++) {
- SV *arg = NULL;
- if (proto->array[i].arg)
- arg = PerlIO_sv_dup(aTHX_ proto->array[i].arg,param);
+ SV *arg = proto->array[i].arg;
+#ifdef sv_dup
+ if (arg && param)
+ arg = sv_dup(arg, param);
+#else
+ PERL_UNUSED_ARG(param);
+#endif
PerlIO_list_push(aTHX_ list, proto->array[i].funcs, arg);
}
}
PerlIO_funcs * const layer =
PerlIO_find_layer(aTHX_ s, llen, 1);
if (layer) {
+ SV *arg = NULL;
+ if (as)
+ arg = newSVpvn(as, alen);
PerlIO_list_push(aTHX_ av, layer,
- (as) ? newSVpvn(as,
- alen) :
- &PL_sv_undef);
+ (arg) ? arg : &PL_sv_undef);
+ if (arg)
+ SvREFCNT_dec(arg);
}
else {
if (ckWARN(WARN_LAYER))
if (layers && *layers) {
PerlIO_list_t *av;
if (incdef) {
- IV i;
- av = PerlIO_list_alloc(aTHX);
- for (i = 0; i < def->cur; i++) {
- PerlIO_list_push(aTHX_ av, def->array[i].funcs,
- def->array[i].arg);
- }
+ av = PerlIO_clone_list(aTHX_ def, NULL);
}
else {
av = def;
PerlIOl *l = *f;
layera = PerlIO_list_alloc(aTHX);
while (l) {
- SV * const arg = (l->tab->Getarg)
- ? (*l->tab->Getarg) (aTHX_ &l, NULL, 0)
- : &PL_sv_undef;
- PerlIO_list_push(aTHX_ layera, l->tab, arg);
+ SV *arg = NULL;
+ if (l->tab->Getarg)
+ arg = (*l->tab->Getarg) (aTHX_ &l, NULL, 0);
+ PerlIO_list_push(aTHX_ layera, l->tab,
+ (arg) ? arg : &PL_sv_undef);
+ if (arg)
+ SvREFCNT_dec(arg);
l = *PerlIONext(&l);
}
}
return NULL;
#ifdef sv_dup
if (param) {
- return sv_dup(arg, param);
+ arg = sv_dup(arg, param);
+ SvREFCNT_inc_simple_void_NN(arg);
+ return arg;
}
else {
return newSVsv(arg);
}
if (f) {
PerlIO_funcs * const self = PerlIOBase(o)->tab;
- SV *arg;
+ SV *arg = NULL;
char buf[8];
PerlIO_debug("PerlIOBase_dup %s f=%p o=%p param=%p\n",
self->name, (void*)f, (void*)o, (void*)param);
if (self->Getarg)
arg = (*self->Getarg)(aTHX_ o, param, flags);
- else {
- arg = NULL;
- }
f = PerlIO_push(aTHX_ f, self, PerlIO_modestr(o,buf), arg);
- if (arg) {
+ if (arg)
SvREFCNT_dec(arg);
- }
}
return f;
}