summaryrefslogtreecommitdiffhomepage
path: root/libbb/procps.c
diff options
context:
space:
mode:
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 ba3d25050..fd19621db 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);