diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2014-07-23 15:28:37 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2014-07-23 15:28:37 +0200 |
commit | a2f7d03d4ef7f606680894693f52150a8eb1ac28 (patch) | |
tree | 9adb83fb124b72cf8d4e4f4dce5a32acd15aff62 /sys/src/cmd/rc/code.c | |
parent | 2bdd2663dbea21a0718b718965a1db75dbf2fdb4 (diff) |
rc: fix slow Xqdol(), avoid recursion in conclist(), estrdup(), avoid copying
Xqdol() used to take quadratic time because of strcat(),
the code isnt really needed as list2str() aready does the
same thing in linear time without the strcat().
add estrdup() which uses emalloc() so allocation error are
catched.
move strdups() of name from callers into newvar().
avoid recursion of conclist(), and avoid copying of word
strings by providing Newword() function which doesnt copy
the word string.
Diffstat (limited to 'sys/src/cmd/rc/code.c')
-rw-r--r-- | sys/src/cmd/rc/code.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/src/cmd/rc/code.c b/sys/src/cmd/rc/code.c index 3618838e3..7d1abbb3a 100644 --- a/sys/src/cmd/rc/code.c +++ b/sys/src/cmd/rc/code.c @@ -56,7 +56,7 @@ void cleanhere(char *f) { emitf(Xdelhere); - emits(strdup(f)); + emits(estrdup(f)); } char* @@ -258,7 +258,7 @@ outcode(tree *t, int eflag) else{ emitf(Xmark); emitf(Xword); - emits(strdup("*")); + emits(estrdup("*")); emitf(Xdol); } emitf(Xmark); /* dummy value for Xlocal */ @@ -275,7 +275,7 @@ outcode(tree *t, int eflag) break; case WORD: emitf(Xword); - emits(strdup(t->str)); + emits(estrdup(t->str)); break; case DUP: if(t->rtype==DUPFD){ |