gilberto...@gmail.com
unread,Oct 4, 2017, 4:55:20 PM10/4/17Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to uthash
Hello,
I started experimenting with uthash (great project !) to handle a fairly large dynamic ip cache.
Before changing all my code I started making some tests and it seems very nice and easy to use. One thing that is not clear to me is how deletion of first element in the hashtable works.
Let's say as example, I have this big hashtable with IPs and at a certain moment I need to purge some elements and incidentally the first element has to be deleted.
What I do is a classic:
struct mycache
{
int key,
struct *mycontents;
UT_hash_handle hh;
};
static struct mycache *cache = NULL;
void purgecache(struct mycache *)
{
HASH_ITER(hh,mycache,myentry,tmp)
{
if (mychache->hastodelete == TRUE)
{
HASH_DEL(mycache,myentry)
free(myentry->mycontents);
free(myentry);
}
}
}
int main(int argc, char**argv)
{
.... all cache creation stuff ...
purgecache(cache);
}
This is a stupid example, but if the head changes, who's going to update it ?
I have to admit that I still hadn't time to read the source code, I'll probably do in the next days, but was just curious if anybody happened to encounter and solve this, I'm scratching my head in the meanwhile, probably missing something very stupid :-)
Thanks
Gilberto