diff options
| author | Marko Kreen | 2014-04-30 16:30:32 +0000 |
|---|---|---|
| committer | Marko Kreen | 2014-04-30 16:30:32 +0000 |
| commit | 1497b4c40a873cfc5bbcd7f95dd92fb08f256db4 (patch) | |
| tree | 2e02d54bcb778ff4707af06bc9643d014cc70150 /usual/heap.c | |
| parent | 2c1cb7f9bfa0a2a183354eb2630a3e4136d0f96b (diff) | |
heap: heap_destroy() works on NULL argument
Diffstat (limited to 'usual/heap.c')
| -rw-r--r-- | usual/heap.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/usual/heap.c b/usual/heap.c index 4145f84..79ffcf6 100644 --- a/usual/heap.c +++ b/usual/heap.c @@ -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) |
