diff options
author | Ron Yorston <rmy@pobox.com> | 2014-01-13 08:55:34 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2014-01-13 08:55:34 +0000 |
commit | 215f730e98215bff8dfacafdaa70e4a11395ad53 (patch) | |
tree | b3dd4c06f0174dde176947a59871c429a58e7241 | |
parent | e371e46fa07eb850d28bc5738e04e6575c32be2e (diff) | |
download | busybox-w32-215f730e98215bff8dfacafdaa70e4a11395ad53.tar.gz busybox-w32-215f730e98215bff8dfacafdaa70e4a11395ad53.tar.bz2 busybox-w32-215f730e98215bff8dfacafdaa70e4a11395ad53.zip |
ash: don't copy localvars list during forkshell
The localvars linked list is only required to tidy up local
variables when a shell function returns. There's no point in
copying it to a child process.
-rw-r--r-- | shell/ash.c | 25 |
1 files changed, 2 insertions, 23 deletions
diff --git a/shell/ash.c b/shell/ash.c index 9678e8092..d104aea1d 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -224,7 +224,6 @@ struct forkshell { | |||
224 | struct globals_var *gvp; | 224 | struct globals_var *gvp; |
225 | struct globals_misc *gmp; | 225 | struct globals_misc *gmp; |
226 | struct tblentry **cmdtable; | 226 | struct tblentry **cmdtable; |
227 | struct localvar *localvars; | ||
228 | /* struct alias **atab; */ | 227 | /* struct alias **atab; */ |
229 | /* struct parsefile *g_parsefile; */ | 228 | /* struct parsefile *g_parsefile; */ |
230 | int fpid; | 229 | int fpid; |
@@ -14031,22 +14030,6 @@ SAVE_PTR((*vpp)->var_text); | |||
14031 | SLIST_COPY_END() | 14030 | SLIST_COPY_END() |
14032 | 14031 | ||
14033 | /* | 14032 | /* |
14034 | * struct localvar | ||
14035 | */ | ||
14036 | SLIST_SIZE_BEGIN(localvar_size,struct localvar) | ||
14037 | var_size(p->vp); | ||
14038 | if (p->text) funcstringsize += strlen(p->text) + 1; | ||
14039 | nodeptrsize += 2; /* p->vp, p->text */ | ||
14040 | SLIST_SIZE_END() | ||
14041 | |||
14042 | SLIST_COPY_BEGIN(localvar_copy,struct localvar) | ||
14043 | (*vpp)->text = nodeckstrdup(vp->text); | ||
14044 | (*vpp)->flags = vp->flags; | ||
14045 | (*vpp)->vp = var_copy(vp->vp); | ||
14046 | SAVE_PTR2((*vpp)->vp, (*vpp)->text); | ||
14047 | SLIST_COPY_END() | ||
14048 | |||
14049 | /* | ||
14050 | * struct strlist | 14033 | * struct strlist |
14051 | */ | 14034 | */ |
14052 | SLIST_SIZE_BEGIN(strlist_size,struct strlist) | 14035 | SLIST_SIZE_BEGIN(strlist_size,struct strlist) |
@@ -14303,7 +14286,6 @@ forkshell_size(struct forkshell *fs) | |||
14303 | globals_var_size(fs->gvp); | 14286 | globals_var_size(fs->gvp); |
14304 | globals_misc_size(fs->gmp); | 14287 | globals_misc_size(fs->gmp); |
14305 | cmdtable_size(fs->cmdtable); | 14288 | cmdtable_size(fs->cmdtable); |
14306 | localvar_size(fs->localvars); | ||
14307 | /* optlist_transfer(sending, fd); */ | 14289 | /* optlist_transfer(sending, fd); */ |
14308 | /* misc_transfer(sending, fd); */ | 14290 | /* misc_transfer(sending, fd); */ |
14309 | 14291 | ||
@@ -14312,7 +14294,7 @@ forkshell_size(struct forkshell *fs) | |||
14312 | funcstringsize += (fs->string ? strlen(fs->string) : 0) + 1; | 14294 | funcstringsize += (fs->string ? strlen(fs->string) : 0) + 1; |
14313 | strlist_size(fs->strlist); | 14295 | strlist_size(fs->strlist); |
14314 | 14296 | ||
14315 | nodeptrsize += 8; /* gvp, gmp, cmdtable, localvars, n, argv, string, strlist */ | 14297 | nodeptrsize += 7; /* gvp, gmp, cmdtable, n, argv, string, strlist */ |
14316 | } | 14298 | } |
14317 | 14299 | ||
14318 | static struct forkshell * | 14300 | static struct forkshell * |
@@ -14327,8 +14309,7 @@ forkshell_copy(struct forkshell *fs) | |||
14327 | new->gvp = globals_var_copy(fs->gvp); | 14309 | new->gvp = globals_var_copy(fs->gvp); |
14328 | new->gmp = globals_misc_copy(fs->gmp); | 14310 | new->gmp = globals_misc_copy(fs->gmp); |
14329 | new->cmdtable = cmdtable_copy(fs->cmdtable); | 14311 | new->cmdtable = cmdtable_copy(fs->cmdtable); |
14330 | new->localvars = localvar_copy(fs->localvars); | 14312 | SAVE_PTR3(new->gvp, new->gmp, new->cmdtable); |
14331 | SAVE_PTR4(new->gvp, new->gmp, new->cmdtable, new->localvars); | ||
14332 | 14313 | ||
14333 | /* new->fs will be reconstructed from new->fpid */ | 14314 | /* new->fs will be reconstructed from new->fpid */ |
14334 | new->n = copynode(fs->n); | 14315 | new->n = copynode(fs->n); |
@@ -14358,7 +14339,6 @@ forkshell_prepare(struct forkshell *fs) | |||
14358 | fs->gvp = ash_ptr_to_globals_var; | 14339 | fs->gvp = ash_ptr_to_globals_var; |
14359 | fs->gmp = ash_ptr_to_globals_misc; | 14340 | fs->gmp = ash_ptr_to_globals_misc; |
14360 | fs->cmdtable = cmdtable; | 14341 | fs->cmdtable = cmdtable; |
14361 | fs->localvars = localvars; | ||
14362 | 14342 | ||
14363 | nodeptrsize = 1; /* NULL terminated */ | 14343 | nodeptrsize = 1; /* NULL terminated */ |
14364 | funcblocksize = 0; | 14344 | funcblocksize = 0; |
@@ -14446,7 +14426,6 @@ forkshell_init(const char *idstr) | |||
14446 | *gvpp = fs->gvp; | 14426 | *gvpp = fs->gvp; |
14447 | gmpp = (struct globals_misc **)&ash_ptr_to_globals_misc; | 14427 | gmpp = (struct globals_misc **)&ash_ptr_to_globals_misc; |
14448 | *gmpp = fs->gmp; | 14428 | *gmpp = fs->gmp; |
14449 | localvars = fs->localvars; | ||
14450 | cmdtable = fs->cmdtable; | 14429 | cmdtable = fs->cmdtable; |
14451 | 14430 | ||
14452 | fs->fp(fs); | 14431 | fs->fp(fs); |