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.
/* compute all pairs shortest path */
/* for unweighted graph */
int i;
- DistType *storage = N_GNEW(n * n, int);
- DistType **dij;
+ DistType *storage = gv_calloc((size_t)(n * n), sizeof(DistType));
Queue Q;
- dij = N_GNEW(n, DistType *);
+ DistType **dij = gv_calloc(n, sizeof(DistType*));
for (i = 0; i < n; i++) {
dij[i] = storage + i * n;
}