MCPcopy Create free account
hub / github.com/ElementsProject/lightning / priorityqueue_new

Function priorityqueue_new

plugins/askrene/child/priorityqueue.c:41–62  ·  view source on GitHub ↗

Allocation of resources for the heap. */

Source from the content-addressed store, hash-verified

39
40/* Allocation of resources for the heap. */
41struct priorityqueue *priorityqueue_new(const tal_t *ctx,
42 size_t max_num_nodes) {
43 struct priorityqueue *q = tal(ctx, struct priorityqueue);
44 /* check allocation */
45 if (!q) return NULL;
46
47 q->value = tal_arr(q, s64, max_num_nodes);
48 q->base = tal_arr(q, u32, max_num_nodes);
49 q->heapptr = tal_arrz(q, u32 *, max_num_nodes);
50
51 /* check allocation */
52 if (!q->value || !q->base || !q->heapptr) return tal_free(q);
53
54 q->heapsize = 0;
55 q->gheap_ctx.fanout = 2;
56 q->gheap_ctx.page_chunks = 1024;
57 q->gheap_ctx.item_size = sizeof(q->base[0]);
58 q->gheap_ctx.less_comparer = priorityqueue_less_comparer;
59 q->gheap_ctx.less_comparer_ctx = NULL;
60 q->gheap_ctx.item_mover = priorityqueue_item_mover;
61 return q;
62}
63
64void priorityqueue_init(struct priorityqueue *q) {
65 const size_t max_num_nodes = tal_count(q->value);

Callers 3

mainFunction · 0.85
dijkstra_pathFunction · 0.85
dijkstra_nearest_sinkFunction · 0.85

Calls 1

tal_freeFunction · 0.85

Tested by 1

mainFunction · 0.68