diff options
author | Marc Espie <espie@cvs.openbsd.org> | 1999-12-16 17:02:46 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 1999-12-16 17:02:46 +0000 |
commit | 9dfc59cc94e1b9ffcaba4f9673a06ce91dd963ae (patch) | |
tree | d2d812c590470d006a86b3e8706e54a4d4b69099 /usr.bin/make/for.c | |
parent | 539b72feadc3d1c6edbcf5e137407d0432b899b1 (diff) |
Allocate buffers as static data structures.
This cuts down quite a lot of malloc, since in actual use,
buffer usage is mostly static.
Diffstat (limited to 'usr.bin/make/for.c')
-rw-r--r-- | usr.bin/make/for.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/usr.bin/make/for.c b/usr.bin/make/for.c index f2541465003..ff1cab7099b 100644 --- a/usr.bin/make/for.c +++ b/usr.bin/make/for.c @@ -1,4 +1,4 @@ -/* $OpenBSD: for.c,v 1.9 1999/12/16 16:41:41 espie Exp $ */ +/* $OpenBSD: for.c,v 1.10 1999/12/16 17:02:45 espie Exp $ */ /* $NetBSD: for.c,v 1.4 1996/11/06 17:59:05 christos Exp $ */ /* @@ -65,7 +65,7 @@ #if 0 static char sccsid[] = "@(#)for.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: for.c,v 1.9 1999/12/16 16:41:41 espie Exp $"; +static char rcsid[] = "$OpenBSD: for.c,v 1.10 1999/12/16 17:02:45 espie Exp $"; #endif #endif /* not lint */ @@ -101,7 +101,7 @@ static char rcsid[] = "$OpenBSD: for.c,v 1.9 1999/12/16 16:41:41 espie Exp $"; static int forLevel = 0; /* Nesting level */ static char *forVar; /* Iteration variable */ -static Buffer forBuf; /* Commands in loop */ +static BUFFER forBuf; /* Commands in loop */ static Lst forLst; /* List of items */ static unsigned long forLineno; /* Line at beginning of loop */ @@ -219,7 +219,7 @@ For_Eval (line) build_words_list(forLst, sub); free(sub); forLineno = Parse_Getlineno(); - forBuf = Buf_Init(0); + Buf_Init(&forBuf, 0); forLevel++; return 1; } @@ -246,8 +246,8 @@ For_Eval (line) } if (forLevel != 0) { - Buf_AddString(forBuf, line); - Buf_AddChar(forBuf, '\n'); + Buf_AddString(&forBuf, line); + Buf_AddChar(&forBuf, '\n'); return 1; } else { @@ -304,19 +304,18 @@ For_Run() { For arg; - if (forVar == NULL || forBuf == NULL || forLst == NULL) + if (forVar == NULL || forLst == NULL) return; arg.var = forVar; - arg.buf = forBuf; + arg.buf = &forBuf; arg.lst = forLst; arg.lineno = forLineno; forVar = NULL; - forBuf = NULL; forLst = NULL; Lst_ForEach(arg.lst, ForExec, (ClientData) &arg); free((Address)arg.var); Lst_Destroy(arg.lst, (void (*) __P((ClientData))) free); - Buf_Destroy(arg.buf, TRUE); + Buf_Destroy(arg.buf); } |