fix memory leak in the C code (#1203)

* fix memory leak when size(deque) == 1

* fix memory leak
pull/1233/head
Yang Le 7 months ago committed by GitHub
parent 0503e740ad
commit db164f6703
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -49,6 +49,9 @@ void delHashMapOpenAddressing(HashMapOpenAddressing *hashMap) {
free(pair);
}
}
free(hashMap->buckets);
free(hashMap->TOMBSTONE);
free(hashMap);
}
/* 哈希函数 */

@ -122,8 +122,8 @@ int pop(LinkedListDeque *deque, bool isFront) {
if (fNext) {
fNext->prev = NULL;
deque->front->next = NULL;
delDoublyListNode(deque->front);
}
delDoublyListNode(deque->front);
deque->front = fNext; // 更新头节点
}
// 队尾出队操作
@ -133,8 +133,8 @@ int pop(LinkedListDeque *deque, bool isFront) {
if (rPrev) {
rPrev->next = NULL;
deque->rear->prev = NULL;
delDoublyListNode(deque->rear);
}
delDoublyListNode(deque->rear);
deque->rear = rPrev; // 更新尾节点
}
deque->queSize--; // 更新队列长度

Loading…
Cancel
Save