aboutsummaryrefslogtreecommitdiff
path: root/lib/mem.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mem.c')
-rw-r--r--lib/mem.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/mem.c b/lib/mem.c
index f90195b..2db82e1 100644
--- a/lib/mem.c
+++ b/lib/mem.c
@@ -62,6 +62,24 @@ gray_realloc(void *ptr, size_t size)
return ptr;
}
+void *
+gray_2nrealloc(void *ptr, size_t *pcount, size_t elsiz)
+{
+ size_t count = *pcount;
+
+ if (!ptr) {
+ if (!count)
+ count = *pcount = 16;
+ return gray_calloc(count, elsiz);
+ }
+ if ((size_t)-1 / 2 / elsiz <= count)
+ gray_raise("Not enough memory");
+ count *= 2;
+ *pcount = count;
+ return gray_realloc(ptr, count * elsiz);
+}
+
+
char *
gray_strdup(const char *str)
{

Return to:

Send suggestions and report system problems to the System administrator.