|
|
@ -123,32 +123,12 @@ struct htname##_entry * htname##_insert(struct htname##_ref *ht, struct htname## |
|
|
|
} \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
\
|
|
|
|
\
|
|
|
|
\
|
|
|
|
|
|
|
|
struct htname##_ref * htname##_remove(struct htname##_ref *ht, codetype code) \
|
|
|
|
#if 0 |
|
|
|
|
|
|
|
/* returns the number of removed items */ \
|
|
|
|
|
|
|
|
int htname##_remove(struct htname##_ref *ht, codetype code) \
|
|
|
|
|
|
|
|
{ \
|
|
|
|
{ \
|
|
|
|
if (!ht) \
|
|
|
|
if (!ht) return NULL; \
|
|
|
|
return -1; \
|
|
|
|
struct htname##_entry *r = htname##_search(ht, code); \
|
|
|
|
uint32_t mask = ht->size - 1; \
|
|
|
|
if (r) r->code = 0; \
|
|
|
|
uint32_t s = hashfn(code)&mask, inc = 0; \
|
|
|
|
return r; \
|
|
|
|
struct htname##_entry *r; \
|
|
|
|
|
|
|
|
/* Flag for removal */ \
|
|
|
|
|
|
|
|
while (ht->items > 0 && (r = htname##lookup(ht, code)) && r->code) { \
|
|
|
|
|
|
|
|
/* FIXME: this cast may not work */ \
|
|
|
|
|
|
|
|
r->code = (codetype)(-1); \
|
|
|
|
|
|
|
|
ht->items--; \
|
|
|
|
|
|
|
|
} \
|
|
|
|
|
|
|
|
/* Remove */ \
|
|
|
|
|
|
|
|
for (uint32_t i = s; i < ht->items; i++) { \
|
|
|
|
|
|
|
|
if (ht->bucket[i].code == (codetype)(-1)) { \
|
|
|
|
|
|
|
|
ht->bucket[i] = (struct htname##_entry){0}; \
|
|
|
|
|
|
|
|
inc++; \
|
|
|
|
|
|
|
|
} \
|
|
|
|
|
|
|
|
} \
|
|
|
|
|
|
|
|
return inc; \
|
|
|
|
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
|
|
|
|
|
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|