C implementation of a heap data structure