I am using the hash-table implementation UThash.
I am inserting elements using the primitive:
HASH_ADD(hh,hash_table,key,keylen,elem);
And retrieving elements with the primitive:
HASH_FIND(hh,hash_table,key,keylen,elem);
For some reason I don't know, the behaviour of hash find is being modified when I call a function. That is to say, uthash does not find an element that is present in the table.
I suspect memory has been compromised in some way.
The function that triggers this failure does not need to execute any code to make UThash fail:
//Note: ct = custom_type
int func1(ct1 *ptr1, ct2 *ptr2, ct3 *ptr3,char **buffer,size_t *size)
{
HASH_FIND(...) //does not work
/**
* code
*/
return 0;
}
int func2(ct1 *ptr1,ct2 *ptr2,ct3 *ptr3)
{
char *buffer;
size_t buf_size;
/**
* code
*/
HASH_FIND(...) // works!
if(func1(ptr1,ptr2,ptr3,&buffer,&buf_size)){
//code
}/*error*/
return 0;
}
int func3(ct1 *ptr1,ct2 *ptr2,ct3 *ptr3)
{
char *buffer;
size_t buf_size;
HASH_FIND(...) // works!
if(func1(ptr1,ptr2,ptr3,&buffer,&buf_size)){
//code
}/*error*/
/**
* code
*/
return 0;
}
So in both func2() and func3() the same behaviour happens. hash_find() starts to fail after I call func1().
All the rest of the code is executed perfectly and correctly.
My obvious question is what could cause such type of failure?
Thank you for reading and be free to ask any additional info.