diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-01-08 19:19:02 +0100 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-01-08 19:19:02 +0100 |
commit | 4efe7ca809c0704e510d07d123f89b0224841101 (patch) | |
tree | b587c9c655ce7e562fbac977be246c2f2d3f77f0 | |
parent | 3f2d2e2ec3e688e46f8c95ea7a168d38bd545a0b (diff) |
Only alloc if n > 0
-rw-r--r-- | da.h | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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) \ |