OSDN Git Service

assume the node deleter is always valid pointer in QHashData::free_helper()
authorIvailo Monev <xakepa10@laimg.moc>
Fri, 12 Jul 2019 11:49:51 +0000 (11:49 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Fri, 12 Jul 2019 11:49:51 +0000 (11:49 +0000)
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
src/core/tools/qhash.cpp

index 2a6d2bb..2a54f9a 100644 (file)
@@ -217,19 +217,17 @@ QHashData *QHashData::detach_helper(void (*node_duplicate)(Node *, void *),
 
 void QHashData::free_helper(void (*node_delete)(Node *))
 {
-    if (node_delete) {
-        Node *this_e = reinterpret_cast<Node *>(this);
-        Node **bucket = reinterpret_cast<Node **>(this->buckets);
-
-        int n = numBuckets;
-        while (n--) {
-            Node *cur = *bucket++;
-            while (cur != this_e) {
-                Node *next = cur->next;
-                node_delete(cur);
-                ::free(cur);
-                cur = next;
-            }
+    Node *this_e = reinterpret_cast<Node *>(this);
+    Node **bucket = reinterpret_cast<Node **>(this->buckets);
+
+    int n = numBuckets;
+    while (n--) {
+        Node *cur = *bucket++;
+        while (cur != this_e) {
+            Node *next = cur->next;
+            node_delete(cur);
+            ::free(cur);
+            cur = next;
         }
     }
     delete [] buckets;