summaryrefslogtreecommitdiff
path: root/builtin/describe.c
diff options
context:
space:
mode:
authorAnders Kaseorg <andersk@ksplice.com>2010-12-09 06:43:32 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-12-09 19:20:25 (GMT)
commit1e1ade1833db42a75f2792b4472748721f73c827 (patch)
treea8b61196c2272cf77697a8bdd3474bdc72ac229b /builtin/describe.c
parent56a5f3afa74c70261dd2319ad76a6810e102026c (diff)
downloadgit-1e1ade1833db42a75f2792b4472748721f73c827.zip
git-1e1ade1833db42a75f2792b4472748721f73c827.tar.gz
git-1e1ade1833db42a75f2792b4472748721f73c827.tar.bz2
describe: Do not use a flex array in struct commit_name
Now add_to_known_names overwrites commit_names in place when multiple tags point to the same commit. This will make it easier to store commit_names in a hash table. Signed-off-by: Anders Kaseorg <andersk@ksplice.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/describe.c')
-rw-r--r--builtin/describe.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/builtin/describe.c b/builtin/describe.c
index 700f740..5b8461d 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -38,7 +38,7 @@ struct commit_name {
unsigned prio:2; /* annotated tag = 2, tag = 1, head = 0 */
unsigned name_checked:1;
unsigned char sha1[20];
- char path[FLEX_ARRAY]; /* more */
+ const char *path;
};
static const char *prio_names[] = {
"head", "lightweight", "annotated",
@@ -85,15 +85,15 @@ static void add_to_known_names(const char *path,
struct commit_name *e = commit->util;
struct tag *tag = NULL;
if (replace_name(e, prio, sha1, &tag)) {
- size_t len = strlen(path)+1;
- free(e);
- e = xmalloc(sizeof(struct commit_name) + len);
+ if (!e) {
+ e = xmalloc(sizeof(struct commit_name));
+ commit->util = e;
+ }
e->tag = tag;
e->prio = prio;
e->name_checked = 0;
hashcpy(e->sha1, sha1);
- memcpy(e->path, path, len);
- commit->util = e;
+ e->path = path;
}
found_names = 1;
}