Hello uthash group!
I just wanted to ask a question regarding the uthash where I am having an issue that by the frequent calling of the function which contains HASH_ADD_PTR API seems to be hanging the program.
For instance, I have a pseudo-code that looks like this:
typedef struct {
char *key;
uint64_t val;
UT_hash_handle hh; /* hashable structure */
} ut_table;
char *uthash_example(char *addr) {
ut_table *ut_hash_table;
HASH_FIND_PTR(hash, &addr, ut_hash_table);
if (enc_dec_table) {
rand_key = ut_hash_table->val;
}
ut_hash_table->key = addr;
ut_hash_table->val = rand_key;
HASH_ADD_PTR(hash, key, ut_hash_table); // causes program to halt
return addr;
}
This function gets called repeatedly throughout the program's execution, and if I comment out HASH_ADD_PTR program works perfectly fine, but with it, it hangs the program.
After trying to fix it, my current guess is that I'm trying to add the key that already exists in the table. However, I haven't been able to resolve this issue, so I wanted to ask for any other possible explanation. Maybe instead of using a PTR as a key, I should use something else?