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;
}
{
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)
{
return insert_decoration(n, obj, decoration);
}
-/* Lookup a decoration pointer */
void *lookup_decoration(struct decoration *n, const struct object *obj)
{
unsigned int j;
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)