Skip to content

Commit

Permalink
heap: heap_destroy() works on NULL argument
Browse files Browse the repository at this point in the history
  • Loading branch information
markokr committed Apr 30, 2014
1 parent 2c1cb7f commit 1497b4c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions usual/heap.c
Expand Up @@ -126,8 +126,10 @@ struct Heap *heap_create(heap_is_better_f is_better_cb, heap_save_pos_f save_pos

void heap_destroy(struct Heap *h)
{
cx_free(h->cx, h->data);
cx_free(h->cx, h);
if (h) {
cx_free(h->cx, h->data);
cx_free(h->cx, h);
}
}

bool heap_reserve(struct Heap *h, unsigned extra)
Expand Down

0 comments on commit 1497b4c

Please sign in to comment.