mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 14:52:01 +00:00
Add some debug assertions for the hash table stuff.
git-svn-id: https://svn.eduke32.com/eduke32@5624 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
9da0c09505
commit
facae6f175
1 changed files with 32 additions and 1 deletions
|
@ -18428,11 +18428,15 @@ static inline uint32_t hash_getcode(const char *s)
|
||||||
|
|
||||||
void hash_add(hashtable_t *t, const char *s, intptr_t key, int32_t replace)
|
void hash_add(hashtable_t *t, const char *s, intptr_t key, int32_t replace)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUGGINGAIDS
|
||||||
|
Bassert(t->items != NULL);
|
||||||
|
#else
|
||||||
if (EDUKE32_PREDICT_FALSE(t->items == NULL))
|
if (EDUKE32_PREDICT_FALSE(t->items == NULL))
|
||||||
{
|
{
|
||||||
initprintf("hash_add(): table not initialized!\n");
|
initprintf("hash_add(): table not initialized!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
uint32_t code = hash_getcode(s) % t->size;
|
uint32_t code = hash_getcode(s) % t->size;
|
||||||
hashitem_t *cur = t->items[code];
|
hashitem_t *cur = t->items[code];
|
||||||
|
@ -18470,11 +18474,15 @@ void hash_add(hashtable_t *t, const char *s, intptr_t key, int32_t replace)
|
||||||
// delete at most once
|
// delete at most once
|
||||||
void hash_delete(hashtable_t *t, const char *s)
|
void hash_delete(hashtable_t *t, const char *s)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUGGINGAIDS
|
||||||
|
Bassert(t->items != NULL);
|
||||||
|
#else
|
||||||
if (t->items == NULL)
|
if (t->items == NULL)
|
||||||
{
|
{
|
||||||
initprintf("hash_delete(): table not initialized!\n");
|
initprintf("hash_delete(): table not initialized!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
uint32_t code = hash_getcode(s) % t->size;
|
uint32_t code = hash_getcode(s) % t->size;
|
||||||
hashitem_t *cur = t->items[code];
|
hashitem_t *cur = t->items[code];
|
||||||
|
@ -18506,11 +18514,15 @@ void hash_delete(hashtable_t *t, const char *s)
|
||||||
|
|
||||||
intptr_t hash_find(const hashtable_t * const t, char const * const s)
|
intptr_t hash_find(const hashtable_t * const t, char const * const s)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUGGINGAIDS
|
||||||
|
Bassert(t->items != NULL);
|
||||||
|
#else
|
||||||
if (t->items == NULL)
|
if (t->items == NULL)
|
||||||
{
|
{
|
||||||
initprintf("hash_find(): table not initialized!\n");
|
initprintf("hash_find(): table not initialized!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
hashitem_t *cur = t->items[hash_getcode(s) % t->size];
|
hashitem_t *cur = t->items[hash_getcode(s) % t->size];
|
||||||
|
|
||||||
|
@ -18527,12 +18539,15 @@ intptr_t hash_find(const hashtable_t * const t, char const * const s)
|
||||||
|
|
||||||
intptr_t hash_findcase(const hashtable_t * const t, char const * const s)
|
intptr_t hash_findcase(const hashtable_t * const t, char const * const s)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUGGINGAIDS
|
||||||
|
Bassert(t->items != NULL);
|
||||||
|
#else
|
||||||
if (t->items == NULL)
|
if (t->items == NULL)
|
||||||
{
|
{
|
||||||
initprintf("hash_findcase(): table not initialized!\n");
|
initprintf("hash_findcase(): table not initialized!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
hashitem_t *cur = t->items[hash_getcode(s) % t->size];
|
hashitem_t *cur = t->items[hash_getcode(s) % t->size];
|
||||||
|
|
||||||
|
@ -18563,11 +18578,15 @@ void inthash_init(inthashtable_t *t)
|
||||||
|
|
||||||
void inthash_loop(inthashtable_t const *t, void (*func)(intptr_t, intptr_t))
|
void inthash_loop(inthashtable_t const *t, void (*func)(intptr_t, intptr_t))
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUGGINGAIDS
|
||||||
|
Bassert(t->items != NULL);
|
||||||
|
#else
|
||||||
if (EDUKE32_PREDICT_FALSE(t->items == NULL))
|
if (EDUKE32_PREDICT_FALSE(t->items == NULL))
|
||||||
{
|
{
|
||||||
initputs("inthash_loop(): table not initialized!\n");
|
initputs("inthash_loop(): table not initialized!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
for (inthashitem_t const * item = t->items, * const items_end = t->items + t->count; item < items_end; ++item)
|
for (inthashitem_t const * item = t->items, * const items_end = t->items + t->count; item < items_end; ++item)
|
||||||
func(item->key, item->value);
|
func(item->key, item->value);
|
||||||
|
@ -18591,11 +18610,15 @@ static inline uint32_t inthash_getcode(intptr_t key)
|
||||||
|
|
||||||
void inthash_add(inthashtable_t *t, intptr_t key, intptr_t value, int32_t replace)
|
void inthash_add(inthashtable_t *t, intptr_t key, intptr_t value, int32_t replace)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUGGINGAIDS
|
||||||
|
Bassert(t->items != NULL);
|
||||||
|
#else
|
||||||
if (EDUKE32_PREDICT_FALSE(t->items == NULL))
|
if (EDUKE32_PREDICT_FALSE(t->items == NULL))
|
||||||
{
|
{
|
||||||
initputs("inthash_add(): table not initialized!\n");
|
initputs("inthash_add(): table not initialized!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
inthashitem_t * seeker = t->items + inthash_getcode(key) % t->count;
|
inthashitem_t * seeker = t->items + inthash_getcode(key) % t->count;
|
||||||
|
|
||||||
|
@ -18647,11 +18670,15 @@ void inthash_add(inthashtable_t *t, intptr_t key, intptr_t value, int32_t replac
|
||||||
// delete at most once
|
// delete at most once
|
||||||
void inthash_delete(inthashtable_t *t, intptr_t key)
|
void inthash_delete(inthashtable_t *t, intptr_t key)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUGGINGAIDS
|
||||||
|
Bassert(t->items != NULL);
|
||||||
|
#else
|
||||||
if (EDUKE32_PREDICT_FALSE(t->items == NULL))
|
if (EDUKE32_PREDICT_FALSE(t->items == NULL))
|
||||||
{
|
{
|
||||||
initputs("inthash_delete(): table not initialized!\n");
|
initputs("inthash_delete(): table not initialized!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
inthashitem_t * seeker = t->items + inthash_getcode(key) % t->count;
|
inthashitem_t * seeker = t->items + inthash_getcode(key) % t->count;
|
||||||
|
|
||||||
|
@ -18680,11 +18707,15 @@ void inthash_delete(inthashtable_t *t, intptr_t key)
|
||||||
|
|
||||||
intptr_t inthash_find(inthashtable_t const *t, intptr_t key)
|
intptr_t inthash_find(inthashtable_t const *t, intptr_t key)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUGGINGAIDS
|
||||||
|
Bassert(t->items != NULL);
|
||||||
|
#else
|
||||||
if (EDUKE32_PREDICT_FALSE(t->items == NULL))
|
if (EDUKE32_PREDICT_FALSE(t->items == NULL))
|
||||||
{
|
{
|
||||||
initputs("inthash_find(): table not initialized!\n");
|
initputs("inthash_find(): table not initialized!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
inthashitem_t const * seeker = t->items + inthash_getcode(key) % t->count;
|
inthashitem_t const * seeker = t->items + inthash_getcode(key) % t->count;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue