diff options
author | jilles <jilles@FreeBSD.org> | 2010-11-23 22:17:39 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2010-11-23 22:17:39 +0000 |
commit | 7377de8f916e2389e9f1c47ca8f7de558aaca6ef (patch) | |
tree | ff9e8102b66741a601dc54d4455bad759b583a8b /bin/sh/memalloc.c | |
parent | 77837b201a907898ee7c79f6a8584102187a089a (diff) | |
download | FreeBSD-src-7377de8f916e2389e9f1c47ca8f7de558aaca6ef.zip FreeBSD-src-7377de8f916e2389e9f1c47ca8f7de558aaca6ef.tar.gz |
sh: Code size optimizations to "stack string" memory allocation:
* Prefer one CHECKSTRSPACE with multiple USTPUTC to multiple STPUTC.
* Add STPUTS macro (based on function) and use it instead of loops that add
nul-terminated strings to the stack string.
No functional change is intended, but code size is about 1K less on i386.
Diffstat (limited to 'bin/sh/memalloc.c')
-rw-r--r-- | bin/sh/memalloc.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/bin/sh/memalloc.c b/bin/sh/memalloc.c index 9158719..d00b4d9 100644 --- a/bin/sh/memalloc.c +++ b/bin/sh/memalloc.c @@ -340,3 +340,20 @@ ungrabstackstr(char *s, char *p) stacknxt = s; sstrnleft = stacknleft - (p - s); } + + +char * +stputbin(const char *data, int len, char *p) +{ + int i; + + for (i = 0; i < len; i++) + STPUTC(data[i], p); + return (p); +} + +char * +stputs(const char *data, char *p) +{ + return (stputbin(data, strlen(data), p)); +} |