Fix insertion into C heap.
commit6b4cb6f90d538c13ec747fd0e415054d791f2ae9
authorMatus Tejiscak <ziman@functor.sk>
dateFri 22 Jan 2016, 13:19 (11 years ago)
parentbf37049
rts/idris_heap.c+6−2
@@ -44,10 +44,14 @@ void c_heap_insert_if_needed(CHeap * heap, CHeapItem * item)
4444{
4545 if (item->prev_next != NULL) return; // already inserted
4646
47− heap->first->prev_next = &item->next;
48− item->prev_next = &heap->first;
47+ if (heap->first != NULL)
48+ {
49+ heap->first->prev_next = &item->next;
50+ }
4951
52+ item->prev_next = &heap->first;
5053 item->next = heap->first;
54+
5155 heap->first = item;
5256}
5357