summaryrefslogtreecommitdiffstats
path: root/lib.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-10-17 19:58:00 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-10-17 19:58:00 -0700
commitfc450ffb9cc44781fa50b789dd5394e3f8937b36 (patch)
tree55387d188854f77f205b6439d1eb222e552a7b2d /lib.h
parent3d95abc9d28983a21215c6156dd9d57374cfed53 (diff)
downloadtxr-fc450ffb9cc44781fa50b789dd5394e3f8937b36.tar.gz
txr-fc450ffb9cc44781fa50b789dd5394e3f8937b36.tar.bz2
txr-fc450ffb9cc44781fa50b789dd5394e3f8937b36.zip
New function chk_manage_vec.
This function manages a dynamic array using only the filled size as input, while minimizing reallocations. The allocated size is implicitly always the next power of two at or above the filled size. * lib.c (next_pow_two): New static function. (chk_manage_vec): New function. * lib.h (chk_manage_vec): Declared.
Diffstat (limited to 'lib.h')
-rw-r--r--lib.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib.h b/lib.h
index 0d0228d4..f2ce5f9b 100644
--- a/lib.h
+++ b/lib.h
@@ -535,6 +535,8 @@ mem_t *chk_calloc(size_t n, size_t size);
mem_t *chk_realloc(mem_t *, size_t size);
mem_t *chk_grow_vec(mem_t *old, size_t oldelems, size_t newelems,
size_t elsize);
+mem_t *chk_manage_vec(mem_t *old, size_t oldfilled, size_t newfilled,
+ size_t elsize, mem_t *fillval);
wchar_t *chk_wmalloc(size_t nwchar);
wchar_t *chk_strdup(const wchar_t *str);
char *chk_strdup_utf8(const char *str);