diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-06-08 15:07:00 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-06-09 14:35:32 -0700 |
commit | c9b29b1f9b882195f90405cb1543a9ea786939af (patch) | |
tree | 01d302bba73ee7660035a97622579fc38fcc3f5e | |
parent | 48d93f7f42e2cde420e2c1d3963f8334f32d777c (diff) | |
download | git-c9b29b1f9b882195f90405cb1543a9ea786939af.tar.gz |
fixup! d5ad6c13
As the topic is in 'next' already, I'll leave this floating near the
tip for now, until we can rewind the topic after the next release.
-rw-r--r-- | attr.c | 18 | ||||
-rw-r--r-- | attr.h | 2 |
2 files changed, 15 insertions, 5 deletions
@@ -741,6 +741,11 @@ static int macroexpand_one(int nr, int rem) return rem; } +static int attr_check_is_dynamic(const struct git_attr_check *check) +{ + return (void *)(check->check) != (void *)(check + 1); +} + /* * Collect attributes for path into the array pointed to by * check_all_attr. If num is non-zero, only attributes in check[] are @@ -899,18 +904,23 @@ struct git_attr_check *git_attr_check_alloc(void) return xcalloc(1, sizeof(struct git_attr_check)); } -void git_attr_check_append(struct git_attr_check *check, - const struct git_attr *attr) +struct git_attr_check_elem *git_attr_check_append(struct git_attr_check *check, + const struct git_attr *attr) { + struct git_attr_check_elem *elem; if (check->finalized) die("BUG: append after git_attr_check structure is finalized"); + if (!attr_check_is_dynamic(check)) + die("BUG: appending to a statically initialized git_attr_check"); ALLOC_GROW(check->check, check->check_nr + 1, check->check_alloc); - check->check[check->check_nr++].attr = attr; + elem = &check->check[check->check_nr++]; + elem->attr = attr; + return elem; } void git_attr_check_clear(struct git_attr_check *check) { - if ((void *)(check->check) == (void *)(check + 1)) + if (!attr_check_is_dynamic(check)) die("BUG: clearing a statically initialized git_attr_check"); free(check->check); check->check_nr = 0; @@ -47,7 +47,7 @@ extern int git_check_attr(const char *path, struct git_attr_check *); extern int git_check_attr_counted(const char *, int, struct git_attr_check *); extern struct git_attr_check *git_attr_check_alloc(void); -extern void git_attr_check_append(struct git_attr_check *, const struct git_attr *); +extern struct git_attr_check_elem *git_attr_check_append(struct git_attr_check *, const struct git_attr *); extern void git_attr_check_clear(struct git_attr_check *); extern void git_attr_check_free(struct git_attr_check *); |