From e0a7fc54eb23f925d2ea885fb1b8699931f9001a Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Wed, 2 Jul 2008 11:14:59 +0000 Subject: uname,individual: fix improper printf usage uname,awk: small code shrink function old new delta uname_main 175 166 -9 nvalloc 167 157 -10 evaluate 6381 6370 -11 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-30) Total: -30 bytes --- editors/awk.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'editors') diff --git a/editors/awk.c b/editors/awk.c index cc5dc84b5..44b747b29 100644 --- a/editors/awk.c +++ b/editors/awk.c @@ -852,11 +852,11 @@ static var *nvalloc(int n) if (!g_cb) { size = (n <= MINNVBLOCK) ? MINNVBLOCK : n; - g_cb = xmalloc(sizeof(nvblock) + size * sizeof(var)); + g_cb = xzalloc(sizeof(nvblock) + size * sizeof(var)); g_cb->size = size; g_cb->pos = g_cb->nv; g_cb->prev = pb; - g_cb->next = NULL; + /*g_cb->next = NULL; - xzalloc did it */ if (pb) pb->next = g_cb; } @@ -2028,9 +2028,9 @@ static var *exec_builtin(node *op, var *res) if (i < 0) i = 0; n = (nargs > 2) ? getvar_i(av[2]) : l-i; if (n < 0) n = 0; - s = xmalloc(n+1); + s = xzalloc(n + 1); strncpy(s, as[0]+i, n); - s[n] = '\0'; + /*s[n] = '\0'; - xzalloc did it */ setvar_p(res, s); break; -- cgit v1.2.3