| 76 | /* Insert element into heap. */ |
| 77 | |
| 78 | int |
| 79 | heap_insert (struct heap *heap, void *item) |
| 80 | { |
| 81 | if (heap->capacity - 1 <= heap->count) |
| 82 | heap->array = xpalloc (heap->array, &heap->capacity, 1, -1, |
| 83 | sizeof heap->array[0]); |
| 84 | |
| 85 | heap->array[++heap->count] = item; |
| 86 | heapify_up (heap->array, heap->count, heap->compare); |
| 87 | |
| 88 | return 0; |
| 89 | } |
| 90 | |
| 91 | /* Pop top element off heap. */ |
| 92 |
no test coverage detected