X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pad.h;h=cc3177791297f5a98c09f2f5706a81e41e483b08;hb=7619c85e4dd9a96a05fc0fc72ace9eb2b9f1bc6f;hp=f8a777ed74d0f3eacadb0ba4b195fdc4c045424c;hpb=f3548bdc4d2efd11e139d110e60764b9dae81319;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pad.h b/pad.h index f8a777e..cc31777 100644 --- a/pad.h +++ b/pad.h @@ -1,6 +1,6 @@ /* pad.h * - * Copyright (c) 2002, Larry Wall + * Copyright (C) 2002, by Larry Wall and others * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. @@ -34,11 +34,9 @@ typedef U64TYPE PADOFFSET; /* flags for the pad_new() function */ -typedef enum { - padnew_CLONE = 1, /* this pad is for a cloned CV */ - padnew_SAVE = 2, /* save old globals */ - padnew_SAVESUB = 4 /* also save extra stuff for start of sub */ -} padnew_flags; +#define padnew_CLONE 1 /* this pad is for a cloned CV */ +#define padnew_SAVE 2 /* save old globals */ +#define padnew_SAVESUB 4 /* also save extra stuff for start of sub */ /* values for the pad_tidy() function */ @@ -242,15 +240,17 @@ Clone the state variables associated with running and compiling pads. else \ (dstpad) = av_dup_inc((srcpad), param); -/* note - we set comp/curpad to null rather than duping - otherwise - * we may dup a pad but not the whole padlist, and be left with - * leaked pad. We assume that a sub will get called very soon hereafter - * and comp/curpad will get set to something sensible. DAPM 16-Oct02 */ -/* XXX DAPM -does the same logic appply to comppad_name ? */ +/* NB - we set PL_comppad to null unless it points at a value that + * has already been dup'ed, ie it points to part of an active padlist. + * Otherwise PL_comppad ends up being a leaked scalar in code like + * the following: + * threads->create(sub { threads->create(sub {...} ) } ); + * where the second thread dups the outer sub's comppad but not the + * sub's CV or padlist. */ #define PAD_CLONE_VARS(proto_perl, param) \ - PL_comppad = Null(PAD*); \ - PL_curpad = Null(SV **); \ + PL_comppad = ptr_table_fetch(PL_ptr_table, proto_perl->Icomppad); \ + PL_curpad = PL_comppad ? AvARRAY(PL_comppad) : Null(SV**); \ PL_comppad_name = av_dup(proto_perl->Icomppad_name, param); \ PL_comppad_name_fill = proto_perl->Icomppad_name_fill; \ PL_comppad_name_floor = proto_perl->Icomppad_name_floor; \