You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, the former is slow and the latter is incorrect-if-freeing-is-needed. So the programmer (well, me) might think to write (3?!)
auto *first = myset;
HASH_ITER(hh, myset, item, tmp) {
if (item != first) delete_or_free(item);
}
HASH_CLEAR(hh, myset);
delete_or_free(first);
Right now this works (I think), but it's not "supported" — uthash does not explicitly guarantee that HASH_CLEAR won't look at the prev/next pointers in myset (which are all now dangling and unsafe to read). It would be nice to add a "supported" method for cleaning up a hash table with deletion/freeing. Something like this:
The currently supported ways to clean up a populated hash are:
(1) If deletion/freeing of elements is needed, then
(2) If deletion/freeing is a no-op, then
However, the former is slow and the latter is incorrect-if-freeing-is-needed. So the programmer (well, me) might think to write (3?!)
Right now this works (I think), but it's not "supported" — uthash does not explicitly guarantee that
HASH_CLEAR
won't look at the prev/next pointers inmyset
(which are all now dangling and unsafe to read). It would be nice to add a "supported" method for cleaning up a hash table with deletion/freeing. Something like this:or simply
The text was updated successfully, but these errors were encountered: