diff --git a/plugins/askrene/algorithm.c b/plugins/askrene/algorithm.c index c843a218a..8901c4b35 100644 --- a/plugins/askrene/algorithm.c +++ b/plugins/askrene/algorithm.c @@ -101,10 +101,6 @@ bool dijkstra_path(const tal_t *ctx, const struct graph *graph, bitmap *visited = tal_arrz(this_ctx, bitmap, BITMAP_NWORDS(max_num_nodes)); - if (!visited) - /* bad allocation */ - goto finish; - for (size_t i = 0; i < max_num_nodes; ++i) prev[i].idx = INVALID_INDEX; @@ -158,7 +154,6 @@ bool dijkstra_path(const tal_t *ctx, const struct graph *graph, for (size_t i = 0; i < max_num_nodes; i++) distance[i] = dijkstra_distance[i]; -finish: tal_free(this_ctx); return target_found; } @@ -357,10 +352,6 @@ static struct node dijkstra_nearest_sink(const tal_t *ctx, struct node target = {.idx = INVALID_INDEX}; const tal_t *this_ctx = tal(ctx, tal_t); - if (!this_ctx) - /* bad allocation */ - goto finish; - /* check preconditions */ assert(graph); assert(node_balance); @@ -405,7 +396,6 @@ static struct node dijkstra_nearest_sink(const tal_t *ctx, #ifdef ASKRENE_UNITTEST bitmap *visited = tal_arrz(this_ctx, bitmap, BITMAP_NWORDS(max_num_nodes)); - assert(visited); #endif struct priorityqueue *q; @@ -510,10 +500,6 @@ bool mcf_refinement(const tal_t *ctx, bool solved = false; const tal_t *this_ctx = tal(ctx, tal_t); - if (!this_ctx) - /* bad allocation */ - goto finish; - assert(graph); assert(excess); assert(capacity); @@ -627,9 +613,6 @@ bool simple_mcf(const tal_t *ctx, const struct graph *graph, s64 *capacity, s64 amount, const s64 *cost) { const tal_t *this_ctx = tal(ctx, tal_t); - if (!this_ctx) - /* bad allocation */ - goto fail; assert(graph); const size_t max_num_arcs = graph_max_num_arcs(graph); @@ -647,10 +630,6 @@ bool simple_mcf(const tal_t *ctx, const struct graph *graph, s64 *potential = tal_arrz(this_ctx, s64, max_num_nodes); s64 *excess = tal_arrz(this_ctx, s64, max_num_nodes); - if (!potential || !excess) - /* bad allocation */ - goto fail; - excess[source.idx] = amount; excess[destination.idx] = -amount; diff --git a/plugins/askrene/graph.c b/plugins/askrene/graph.c index 250cdd7df..973e6adcc 100644 --- a/plugins/askrene/graph.c +++ b/plugins/askrene/graph.c @@ -42,10 +42,6 @@ struct graph *graph_new(const tal_t *ctx, const size_t max_num_nodes, struct graph *graph; graph = tal(ctx, struct graph); - /* bad allocation of graph */ - if (!graph) - return graph; - graph->max_num_arcs = max_num_arcs; graph->max_num_nodes = max_num_nodes; graph->arc_dual_bit = arc_dual_bit; @@ -56,12 +52,6 @@ struct graph *graph_new(const tal_t *ctx, const size_t max_num_nodes, graph->node_adjacency_next = tal_arr(graph, struct arc, graph->max_num_arcs); - /* bad allocation of graph components */ - if (!graph->arc_tail || !graph->node_adjacency_first || - !graph->node_adjacency_next) { - return tal_free(graph); - } - /* initialize with invalid indexes so that we know these slots have * never been used, eg. arc/node is newly created */ for (size_t i = 0; i < graph->max_num_arcs; i++)