From 0f8d40747c6c64aecd21be7eb2bd4a1dc2d0885f Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Thu, 17 Nov 2022 17:14:41 -0800 Subject: [PATCH] neatogen compute_apsp_dijkstra: use cgraph wrappers for allocation The lib/cgraph/alloc.h wrappers are similar to the older lib/common/memory.h wrappers except (1) they are header-only and (2) they live in a directory (cgraph) that is at the root of the dependency tree. The long term plan is to replace all use of lib/common/memory.h with lib/cgraph/alloc.h. We can also squash a -Wsign-conversion warning at the same time, noting that the square of a signed number is always non-negative. --- lib/neatogen/kkutils.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/neatogen/kkutils.c b/lib/neatogen/kkutils.c index 82502f2ee..f9db09c89 100644 --- a/lib/neatogen/kkutils.c +++ b/lib/neatogen/kkutils.c @@ -8,7 +8,7 @@ * Contributors: Details at https://graphviz.org *************************************************************************/ - +#include #include #include #include @@ -56,11 +56,9 @@ void empty_neighbors_vec(vtx_data * graph, int vtx, int *vtx_vec) static DistType **compute_apsp_dijkstra(vtx_data * graph, int n) { int i; - DistType *storage; - DistType **dij; - storage = N_GNEW(n * n, DistType); - dij = N_GNEW(n, DistType *); + DistType *storage = gv_calloc((size_t)(n * n), sizeof(DistType)); + DistType **dij = gv_calloc(n, sizeof(DistType*)); for (i = 0; i < n; i++) dij[i] = storage + i * n; -- 2.50.1