create new heap and initialise it
| 161 | |
| 162 | // create new heap and initialise it |
| 163 | heap_t *Heap_new |
| 164 | ( |
| 165 | heap_cmp cmp, // cmp callback used to get an item's priority |
| 166 | void *udata // udata user data passed through to cmp callback |
| 167 | ) { |
| 168 | heap_t *hp = malloc(Heap_sizeof(DEFAULT_CAPACITY)); |
| 169 | |
| 170 | if(!hp) { |
| 171 | return NULL; |
| 172 | } |
| 173 | |
| 174 | Heap_init(hp, cmp, udata, DEFAULT_CAPACITY); |
| 175 | |
| 176 | return hp; |
| 177 | } |
| 178 | |
| 179 | // initialise heap |
| 180 | void Heap_init |