summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDenis Vlasenko2008-08-04 13:20:36 +0000
committerDenis Vlasenko2008-08-04 13:20:36 +0000
commit27842288b393e532e5693f2a2bab94fee73a326d (patch)
tree98535c0fd140c89aa6b83179b11d160e6ed59c28 /include
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 'include')
-rw-r--r--include/libbb.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/libbb.h b/include/libbb.h
index 2dcdeac..f7a6849 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -570,6 +570,10 @@ void *malloc_or_warn(size_t size) FAST_FUNC;
void *xmalloc(size_t size) FAST_FUNC;
void *xzalloc(size_t size) FAST_FUNC;
void *xrealloc(void *old, size_t size) FAST_FUNC;
+/* After xrealloc_vector(v, 4, idx) it's ok to use
+ * at least v[idx] and v[idx+1], for all idx values.
+ * shift specifies how many new elements are added (1: 2, 2: 4... 8: 256...)
+ * when all elements are used up. New elements are zeroed out. */
#define xrealloc_vector(vector, shift, idx) \
xrealloc_vector_helper((vector), (sizeof((vector)[0]) << 8) + (shift), (idx))
void* xrealloc_vector_helper(void *vector, unsigned sizeof_and_shift, int idx) FAST_FUNC;