From: Matthew Fernandez Date: Wed, 12 Jan 2022 03:28:26 +0000 (-0800) Subject: cluster_map: replace boolean array 'assigned' with a bit array X-Git-Tag: 3.0.0~70^2~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3b828a22ef0886ba3d6c074c238135670b791f5b;p=graphviz cluster_map: replace boolean array 'assigned' with a bit array This is more memory efficient. --- diff --git a/lib/neatogen/neatoinit.c b/lib/neatogen/neatoinit.c index 9401c60ef..3c7bf59b8 100644 --- a/lib/neatogen/neatoinit.c +++ b/lib/neatogen/neatoinit.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -188,7 +189,8 @@ static cluster_data* cluster_map(graph_t *mastergraph, graph_t *g) /* array of arrays of node indices in each cluster */ int **cs,*cn; int i,j,nclusters=0; - boolean* assigned = N_NEW(agnnodes(g), boolean); + bitarray_t assigned = {0}; + bitarray_resize_or_exit(&assigned, agnnodes(g)); cluster_data *cdata = GNEW(cluster_data); cdata->ntoplevel = agnnodes(g); @@ -217,7 +219,7 @@ static cluster_data* cluster_map(graph_t *mastergraph, graph_t *g) ind++; } *c++=ind; - assigned[ind]=TRUE; + bitarray_set(assigned, ind, true); cdata->ntoplevel--; } } @@ -225,12 +227,12 @@ static cluster_data* cluster_map(graph_t *mastergraph, graph_t *g) cdata->bb=N_GNEW(cdata->nclusters,boxf); cdata->toplevel=N_GNEW(cdata->ntoplevel,int); for(i=j=0;itoplevel[j++]=i; } } assert(cdata->ntoplevel==agnnodes(g)-cdata->nvars); - free (assigned); + bitarray_reset(&assigned); return cdata; }