Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2014-08-26 14:24:20 +0400
committerJunio C Hamano <gitster@pobox.com>2014-08-27 18:44:27 +0400
commit2e3dfb216991974b60fdb1933eb3331e03383e61 (patch)
treea5b7fc4e71e77832dcbb8c5d5a55de9222ac7972 /log-tree.c
parent2608c24940c80bf379937e4cefee75e2db79e008 (diff)
log-tree: use FLEX_ARRAY in name_decoration
We are already using the flex-array technique; let's annotate it with our usual FLEX_ARRAY macro. Besides being more readable, this is slightly more efficient on compilers that understand flex-arrays. Note that we need to bump the allocation in add_name_decoration, which did not explicitly add one byte for the NUL terminator of the string we are putting into the flex-array (it did not need to before, because the struct itself was over-allocated by one byte). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'log-tree.c')
-rw-r--r--log-tree.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/log-tree.c b/log-tree.c
index 2adf82ba02..de760db1a6 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -77,7 +77,7 @@ int parse_decorate_color_config(const char *var, const int ofs, const char *valu
void add_name_decoration(enum decoration_type type, const char *name, struct object *obj)
{
int nlen = strlen(name);
- struct name_decoration *res = xmalloc(sizeof(struct name_decoration) + nlen);
+ struct name_decoration *res = xmalloc(sizeof(*res) + nlen + 1);
memcpy(res->name, name, nlen + 1);
res->type = type;
res->next = add_decoration(&name_decoration, obj, res);