From: Matthew Fernandez Date: Fri, 18 Nov 2022 01:14:41 +0000 (-0800) Subject: neatogen compute_apsp_dijkstra: use cgraph wrappers for allocation X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0f8d40747c6c64aecd21be7eb2bd4a1dc2d0885f;p=graphviz 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. --- 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;