path: root/Documentation/technical
diff options
authorJeff King <>2016-02-22 22:43:25 (GMT)
committerJunio C Hamano <>2016-02-22 22:50:32 (GMT)
commit3689539127f786f32ff04da374d37cc1f72fb918 (patch)
treeb3e860b9335b096490a581e6b2fdeb3ac9e6e741 /Documentation/technical
parente7792a74bcf7fcd554b4546fc91122b8c2af7d75 (diff)
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 <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'Documentation/technical')
0 files changed, 0 insertions, 0 deletions