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.h | |
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.h')
-rw-r--r-- | bin/sh/memalloc.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/bin/sh/memalloc.h b/bin/sh/memalloc.h index 563927a..88848dd 100644 --- a/bin/sh/memalloc.h +++ b/bin/sh/memalloc.h @@ -61,6 +61,8 @@ void grabstackblock(int); char *growstackstr(void); char *makestrspace(void); void ungrabstackstr(char *, char *); +char *stputbin(const char *data, int len, char *p); +char *stputs(const char *data, char *p); @@ -82,3 +84,5 @@ void ungrabstackstr(char *, char *); #define STTOPC(p) p[-1] #define STADJUST(amount, p) (p += (amount), sstrnleft -= (amount)) #define grabstackstr(p) stalloc(stackblocksize() - sstrnleft) +#define STPUTBIN(s, len, p) p = stputbin((s), (len), p) +#define STPUTS(s, p) p = stputs((s), p) |