diff options
author | Denis Vlasenko | 2007-12-02 08:35:37 +0000 |
---|---|---|
committer | Denis Vlasenko | 2007-12-02 08:35:37 +0000 |
commit | ab801874f852312787c049272c20b14e06ed8195 (patch) | |
tree | 1cfd38cfe48ed6a6625ce559ab7f3e5778a980be /shell | |
parent | 8003e266edbc0ec62a586dd70dcc80dc13e2dbf0 (diff) | |
download | busybox-ab801874f852312787c049272c20b14e06ed8195.zip busybox-ab801874f852312787c049272c20b14e06ed8195.tar.gz |
attack the biggest stack users:
-mkfs_minix_main [busybox_unstripped]: 4288
-mkfs_minix_main [busybox_unstripped]: 4276
-grave [busybox_unstripped]: 4260
(bzip2 users too - not listed)
price we pay in code size increase:
mainSort 2458 2515 +57
grave 1005 1058 +53
sendMTFValues 2177 2195 +18
BZ2_blockSort 122 125 +3
mkfs_minix_main 3070 3022 -48
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/1 up/down: 131/-48) Total: 83 bytes
Diffstat (limited to 'shell')
-rw-r--r-- | shell/msh.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/shell/msh.c b/shell/msh.c index 32953f4..9f95fe2 100644 --- a/shell/msh.c +++ b/shell/msh.c @@ -735,6 +735,9 @@ struct globals { char filechar_cmdbuf[BUFSIZ]; char line[LINELIM]; char child_cmd[LINELIM]; + + char grave__var_name[LINELIM]; + char grave__alt_value[LINELIM]; }; #define G (*ptr_to_globals) @@ -746,6 +749,9 @@ struct globals { #define filechar_cmdbuf (G.filechar_cmdbuf) #define line (G.line ) #define child_cmd (G.child_cmd ) +#define INIT_G() do { \ + PTR_TO_GLOBALS = xzalloc(sizeof(G)); \ +} while (0) #ifdef MSHDEBUG @@ -4042,8 +4048,12 @@ static int grave(int quoted) ignore_once = 1; if (*src == '$' && !ignore && !ignore_once) { struct var *vp; + /* moved to G to reduce stack usage char var_name[LINELIM]; char alt_value[LINELIM]; + */ +#define var_name (G.grave__var_name) +#define alt_value (G.grave__alt_value) int var_index = 0; int alt_index = 0; char operator = 0; @@ -4131,6 +4141,8 @@ static int grave(int quoted) count++; } } +#undef var_name +#undef alt_value } else { *dest++ = *src++; count++; @@ -5173,7 +5185,8 @@ int msh_main(int argc, char **argv) char *name, **ap; int (*iof) (struct ioarg *); - PTR_TO_GLOBALS = xzalloc(sizeof(G)); + INIT_G(); + sharedbuf.id = AFID_NOBUF; mainbuf.id = AFID_NOBUF; e.linep = line; |