From aaff3de409a2242c76a79de5606c500d13564e9a Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Thu, 19 Sep 2024 15:32:22 -0700 Subject: [PATCH] Free memory [skip ci] --- src/hnswscan.c | 2 ++ src/hnswutils.c | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/hnswscan.c b/src/hnswscan.c index bcfefb5..9b8c9a3 100644 --- a/src/hnswscan.c +++ b/src/hnswscan.c @@ -226,6 +226,8 @@ hnswgettuple(IndexScanDesc scan, ScanDirection dir) if (element->heaptidsLength == 0) { so->w = list_delete_last(so->w); + pfree(element); + pfree(hc); continue; } diff --git a/src/hnswutils.c b/src/hnswutils.c index bc72813..5a114b3 100644 --- a/src/hnswutils.c +++ b/src/hnswutils.c @@ -938,10 +938,14 @@ HnswSearchLayer(char *base, Datum q, List *ep, int ef, int lc, Relation index, F /* No need to decrement wlen */ if (wlen > ef) { - HnswCandidate *hc = HnswGetPairingHeapCandidate(w_node, pairingheap_remove_first(W)); + HnswPairingHeapNode *node = pairingheap_container(HnswPairingHeapNode, w_node, pairingheap_remove_first(W)); + HnswCandidate *hc = node->inner; if (discarded != NULL) *discarded = lappend(*discarded, hc); + + /* TODO */ + /* pfree(node); */ } } } @@ -950,9 +954,12 @@ HnswSearchLayer(char *base, Datum q, List *ep, int ef, int lc, Relation index, F /* Add each element of W to w */ while (!pairingheap_is_empty(W)) { - HnswCandidate *hc = HnswGetPairingHeapCandidate(w_node, pairingheap_remove_first(W)); + HnswPairingHeapNode *node = pairingheap_container(HnswPairingHeapNode, w_node, pairingheap_remove_first(W)); + HnswCandidate *hc = node->inner; w = lappend(w, hc); + + pfree(node); } return w;