diff options
Diffstat (limited to 'bin/sh/memalloc.c')
-rw-r--r-- | bin/sh/memalloc.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/bin/sh/memalloc.c b/bin/sh/memalloc.c index 01bddb2..9158719 100644 --- a/bin/sh/memalloc.c +++ b/bin/sh/memalloc.c @@ -295,6 +295,13 @@ grabstackblock(int len) * is space for at least one character. */ +static char * +growstrstackblock(int n) +{ + growstackblock(); + sstrnleft = stackblocksize() - n; + return stackblock() + n; +} char * growstackstr(void) @@ -304,12 +311,10 @@ growstackstr(void) len = stackblocksize(); if (herefd >= 0 && len >= 1024) { xwrite(herefd, stackblock(), len); - sstrnleft = len - 1; + sstrnleft = len; return stackblock(); } - growstackblock(); - sstrnleft = stackblocksize() - len - 1; - return stackblock() + len; + return growstrstackblock(len); } @@ -323,9 +328,7 @@ makestrspace(void) int len; len = stackblocksize() - sstrnleft; - growstackblock(); - sstrnleft = stackblocksize() - len; - return stackblock() + len; + return growstrstackblock(len); } |