diff options
Diffstat (limited to 'decorate.c')
-rw-r--r-- | decorate.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/decorate.c b/decorate.c index 270eb25197..de31331fa4 100644 --- a/decorate.c +++ b/decorate.c @@ -14,20 +14,20 @@ static unsigned int hash_obj(const struct object *obj, unsigned int n) static void *insert_decoration(struct decoration *n, const struct object *base, void *decoration) { int size = n->size; - struct object_decoration *hash = n->hash; + struct decoration_entry *entries = n->entries; unsigned int j = hash_obj(base, size); - while (hash[j].base) { - if (hash[j].base == base) { - void *old = hash[j].decoration; - hash[j].decoration = decoration; + while (entries[j].base) { + if (entries[j].base == base) { + void *old = entries[j].decoration; + entries[j].decoration = decoration; return old; } if (++j >= size) j = 0; } - hash[j].base = base; - hash[j].decoration = decoration; + entries[j].base = base; + entries[j].decoration = decoration; n->nr++; return NULL; } @@ -36,24 +36,23 @@ static void grow_decoration(struct decoration *n) { int i; int old_size = n->size; - struct object_decoration *old_hash = n->hash; + struct decoration_entry *old_entries = n->entries; n->size = (old_size + 1000) * 3 / 2; - n->hash = xcalloc(n->size, sizeof(struct object_decoration)); + n->entries = xcalloc(n->size, sizeof(struct decoration_entry)); n->nr = 0; for (i = 0; i < old_size; i++) { - const struct object *base = old_hash[i].base; - void *decoration = old_hash[i].decoration; + const struct object *base = old_entries[i].base; + void *decoration = old_entries[i].decoration; if (!decoration) continue; insert_decoration(n, base, decoration); } - free(old_hash); + free(old_entries); } -/* Add a decoration pointer, return any old one */ void *add_decoration(struct decoration *n, const struct object *obj, void *decoration) { @@ -64,7 +63,6 @@ void *add_decoration(struct decoration *n, const struct object *obj, return insert_decoration(n, obj, decoration); } -/* Lookup a decoration pointer */ void *lookup_decoration(struct decoration *n, const struct object *obj) { unsigned int j; @@ -74,7 +72,7 @@ void *lookup_decoration(struct decoration *n, const struct object *obj) return NULL; j = hash_obj(obj, n->size); for (;;) { - struct object_decoration *ref = n->hash + j; + struct decoration_entry *ref = n->entries + j; if (ref->base == obj) return ref->decoration; if (!ref->base) |