aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-01-08 19:19:02 +0100
committerThomas Voss <mail@thomasvoss.com> 2024-01-08 19:19:02 +0100
commit4efe7ca809c0704e510d07d123f89b0224841101 (patch)
treeb587c9c655ce7e562fbac977be246c2f2d3f77f0
parent3f2d2e2ec3e688e46f8c95ea7a168d38bd545a0b (diff)
Only alloc if n > 0
-rw-r--r--da.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/da.h b/da.h
index 8f99d01..b3ef1cb 100644
--- a/da.h
+++ b/da.h
@@ -87,9 +87,10 @@
#define dainit(a, n) \
do { \
(a)->buf = NULL; \
- (a)->cap = n; \
+ (a)->cap = (n); \
(a)->len = 0; \
- DA_ALLOC((a)->buf, (a)->cap); \
+ if (n) \
+ DA_ALLOC((a)->buf, (a)->cap); \
} while (0)
#define dapush(a, x) \