summaryrefslogtreecommitdiff
path: root/Documentation
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2016-02-22 22:43:25 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-02-22 22:50:32 (GMT)
commit3689539127f786f32ff04da374d37cc1f72fb918 (patch)
treeb3e860b9335b096490a581e6b2fdeb3ac9e6e741 /Documentation
parente7792a74bcf7fcd554b4546fc91122b8c2af7d75 (diff)
downloadgit-3689539127f786f32ff04da374d37cc1f72fb918.zip
git-3689539127f786f32ff04da374d37cc1f72fb918.tar.gz
git-3689539127f786f32ff04da374d37cc1f72fb918.tar.bz2
add helpers for allocating flex-array structs
Allocating a struct with a flex array is pretty simple in practice: you over-allocate the struct, then copy some data into the over-allocation. But it can be a slight pain to make sure you're allocating and copying the right amounts. This patch adds a few helpers to turn simple cases of flex-array struct allocation into a one-liner that properly checks for overflow. See the embedded documentation for details. Ideally we could provide a more flexible version that could handle multiple strings, like: FLEX_ALLOC_FMT(ref, name, "%s%s", prefix, name); But we have to implement this as a macro (because of the offset calculation of the flex member), which means we would need all compilers to support variadic macros. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'Documentation')
0 files changed, 0 insertions, 0 deletions