summaryrefslogtreecommitdiffstats
path: root/dstring.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2020-09-18 16:39:40 -0400
committerTavian Barnes <tavianator@tavianator.com>2020-10-13 13:42:11 -0400
commitc565e665781f39cf31c64d85c76224c2fffa9f7d (patch)
treeed8d167bd38d2d23f39875ffe25793de3416948a /dstring.c
parentfd0b968b5afe28d9adcfbc9aef17bc83d6eaf84b (diff)
downloadbfs-c565e665781f39cf31c64d85c76224c2fffa9f7d.tar.xz
util: New BFS_FLEX_SIZEOF() macro for more precise flexible array allocations
See http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_282.htm for all the fun behind this.
Diffstat (limited to 'dstring.c')
-rw-r--r--dstring.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/dstring.c b/dstring.c
index d370598..bfcf9bd 100644
--- a/dstring.c
+++ b/dstring.c
@@ -37,7 +37,7 @@ static struct dstring *dstrheader(const char *dstr) {
/** Get the correct size for a dstring with the given capacity. */
static size_t dstrsize(size_t capacity) {
- return sizeof(struct dstring) + capacity + 1;
+ return BFS_FLEX_SIZEOF(struct dstring, data, capacity + 1);
}
/** Allocate a dstring with the given contents. */