MCPcopy Create free account
hub / github.com/coreutils/coreutils / heap_insert

Function heap_insert

gl/lib/heap.c:78–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76/* Insert element into heap. */
77
78int
79heap_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

Callers 1

queue_insertFunction · 0.85

Calls 1

heapify_upFunction · 0.85

Tested by

no test coverage detected