summaryrefslogtreecommitdiffstats
path: root/mpvcore/mp_talloc.h
diff options
context:
space:
mode:
Diffstat (limited to 'mpvcore/mp_talloc.h')
-rw-r--r--mpvcore/mp_talloc.h14
1 files changed, 6 insertions, 8 deletions
diff --git a/mpvcore/mp_talloc.h b/mpvcore/mp_talloc.h
index 1dcb0bce07..eb62a21109 100644
--- a/mpvcore/mp_talloc.h
+++ b/mpvcore/mp_talloc.h
@@ -23,21 +23,19 @@
#include "compat/compiler.h"
#define MP_TALLOC_ELEMS(p) (talloc_get_size(p) / sizeof((p)[0]))
-#define MP_GROW_ARRAY(p, nextidx) do { \
- if ((nextidx) == MP_TALLOC_ELEMS(p)) \
- (p) = talloc_realloc_size(NULL, p, talloc_get_size(p) * 2); } while (0)
-#define MP_RESIZE_ARRAY(ctx, p, count) do { \
+
+#define MP_RESIZE_ARRAY(ctx, p, count) do { \
(p) = talloc_realloc_size((ctx), p, (count) * sizeof((p)[0])); } while (0)
#define MP_TARRAY_GROW(ctx, p, nextidx) \
do { \
size_t nextidx_ = (nextidx); \
- size_t nelems_ = MP_TALLOC_ELEMS(p); \
- if (nextidx_ >= nelems_) \
- (p) = talloc_realloc_size(ctx, p, \
- (nextidx_ + 1) * sizeof((p)[0]) * 2);\
+ if (nextidx_ >= MP_TALLOC_ELEMS(p)) \
+ MP_RESIZE_ARRAY(ctx, p, (nextidx_ + 1) * 2);\
} while (0)
+#define MP_GROW_ARRAY(p, nextidx) MP_TARRAY_GROW(NULL, p, nextidx)
+
#define MP_TARRAY_APPEND(ctx, p, idxvar, ...) \
do { \
MP_TARRAY_GROW(ctx, p, idxvar); \