aboutsummaryrefslogtreecommitdiffstats
path: root/reftable/basics.h
diff options
context:
space:
mode:
Diffstat (limited to 'reftable/basics.h')
-rw-r--r--reftable/basics.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/reftable/basics.h b/reftable/basics.h
index 36beda2c25..259f4c274c 100644
--- a/reftable/basics.h
+++ b/reftable/basics.h
@@ -129,6 +129,16 @@ char *reftable_strdup(const char *str);
REFTABLE_REALLOC_ARRAY(x, alloc); \
} \
} while (0)
+
+#define REFTABLE_ALLOC_GROW_OR_NULL(x, nr, alloc) do { \
+ void *reftable_alloc_grow_or_null_orig_ptr = (x); \
+ REFTABLE_ALLOC_GROW((x), (nr), (alloc)); \
+ if (!(x)) { \
+ reftable_free(reftable_alloc_grow_or_null_orig_ptr); \
+ alloc = 0; \
+ } \
+} while (0)
+
#define REFTABLE_FREE_AND_NULL(p) do { reftable_free(p); (p) = NULL; } while (0)
#ifndef REFTABLE_ALLOW_BANNED_ALLOCATORS