Skip to content

Commit

Permalink
Fix leak, re issue #664
Browse files Browse the repository at this point in the history
  • Loading branch information
infradig committed Feb 3, 2025
1 parent a4ed6e3 commit d0b74a6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
14 changes: 5 additions & 9 deletions src/heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,20 +164,16 @@ void trim_heap(query *q)
if (a->nbr < q->st.heap_nbr)
break;

cell *c = a->cells;

for (pl_idx i = 0; i < a->idx; i++, c++)
unshare_cell(c);

page *save = a;
q->heap_pages = a = a->next;
free(save->cells);
free(save);
}

#if 0
const page *a = q->heap_pages;

for (pl_idx i = q->st.hp; a && (i < a->idx); i++) {
cell *c = a->cells + i;
init_cell(c);
}
#endif
}

#define deep_copy(c) \
Expand Down
14 changes: 13 additions & 1 deletion src/query.c
Original file line number Diff line number Diff line change
Expand Up @@ -1886,8 +1886,20 @@ void query_destroy(query *q)
c->attrs = tr->attrs;
}

for (int i = 0; i < MAX_QUEUES; i++)
for (int i = 0; i < MAX_QUEUES; i++) {
cell *c = q->queue[i];
for (pl_idx j = 0; j < q->qp[i]; j++, c++)
unshare_cell(c);

free(q->queue[i]);
}

slot *e = q->slots;

for (pl_idx i = 0; i < q->st.sp; i++, e++) {
cell *c = &e->c;
unshare_cell(c);
}

while (q->tasks) {
query *task = q->tasks->next;
Expand Down

0 comments on commit d0b74a6

Please sign in to comment.