diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2020-09-18 16:39:40 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2020-10-13 13:42:11 -0400 |
commit | c565e665781f39cf31c64d85c76224c2fffa9f7d (patch) | |
tree | ed8d167bd38d2d23f39875ffe25793de3416948a /bftw.c | |
parent | fd0b968b5afe28d9adcfbc9aef17bc83d6eaf84b (diff) | |
download | bfs-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 'bftw.c')
-rw-r--r-- | bftw.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -300,7 +300,7 @@ static size_t bftw_child_nameoff(const struct bftw_file *parent) { /** Create a new bftw_file. */ static struct bftw_file *bftw_file_new(struct bftw_cache *cache, struct bftw_file *parent, const char *name) { size_t namelen = strlen(name); - size_t size = sizeof(struct bftw_file) + namelen + 1; + size_t size = BFS_FLEX_SIZEOF(struct bftw_file, name, namelen + 1); struct bftw_file *file = malloc(size); if (!file) { |