summaryrefslogtreecommitdiff
path: root/libbb/procps.c
diff options
context:
space:
mode:
authorDenis Vlasenko2008-08-04 13:20:36 +0000
committerDenis Vlasenko2008-08-04 13:20:36 +0000
commit27842288b393e532e5693f2a2bab94fee73a326d (patch)
tree98535c0fd140c89aa6b83179b11d160e6ed59c28 /libbb/procps.c
parent2b576b8e76ee0dc548f46489e2546b7ed70d080d (diff)
downloadbusybox-27842288b393e532e5693f2a2bab94fee73a326d.zip
busybox-27842288b393e532e5693f2a2bab94fee73a326d.tar.gz
libbb: make xrealloc_vector zero out the realloc'ed tail
function old new delta xrealloc_vector_helper 51 76 +25 man_main 712 705 -7 act 250 234 -16 create_list 91 70 -21 getopt_main 695 664 -31 load_dep_bb 281 248 -33 fileAction 744 709 -35 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/6 up/down: 25/-143) Total: -118 bytes
Diffstat (limited to 'libbb/procps.c')
-rw-r--r--libbb/procps.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libbb/procps.c b/libbb/procps.c
index ba3d250..fd19621 100644
--- a/libbb/procps.c
+++ b/libbb/procps.c
@@ -45,8 +45,8 @@ static int get_cached(cache_t *cp, unsigned id)
for (i = 0; i < cp->size; i++)
if (cp->cache[i].id == id)
return i;
- i = cp->size;
- cp->cache = xrealloc_vector(cp->cache, 2, cp->size++);
+ i = cp->size++;
+ cp->cache = xrealloc_vector(cp->cache, 2, i);
cp->cache[i++].id = id;
return -i;
}
@@ -59,8 +59,8 @@ static char* get_cached(cache_t *cp, unsigned id, ug_func* fp)
for (i = 0; i < cp->size; i++)
if (cp->cache[i].id == id)
return cp->cache[i].name;
- i = cp->size;
- cp->cache = xrealloc_vector(cp->cache, 2, cp->size++);
+ i = cp->size++;
+ cp->cache = xrealloc_vector(cp->cache, 2, i);
cp->cache[i].id = id;
/* Never fails. Generates numeric string if name isn't found */
fp(cp->cache[i].name, sizeof(cp->cache[i].name), id);