Skip to content
Snippets Groups Projects
Commit 4ab48edb authored by Ben Gamari's avatar Ben Gamari Committed by Marge Bot
Browse files

rts/Hash: Don't iterate over chunks if we don't need to free data

When freeing a `HashTable` there is no reason to walk over the hash list
before freeing it if the user has not given us a `dataFreeFun`.

Noticed while looking at #24410.
parent 401dfe7b
No related branches found
No related tags found
No related merge requests found
......@@ -440,14 +440,15 @@ freeHashTable(HashTable *table, void (*freeDataFun)(void *) )
/* Free table segments */
while (segment >= 0) {
while (index >= 0) {
HashList *next;
for (HashList *hl = table->dir[segment][index]; hl != NULL; hl = next) {
next = hl->next;
if (freeDataFun != NULL)
if (freeDataFun) {
while (index >= 0) {
HashList *next;
for (HashList *hl = table->dir[segment][index]; hl != NULL; hl = next) {
next = hl->next;
(*freeDataFun)((void *) hl->data);
}
index--;
}
index--;
}
stgFree(table->dir[segment]);
segment--;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment