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.
Note that in this change we can drop some explicit initialization because the
cgraph wrappers zero-initialize.
*/
static tgraph *mkTriGraph(surface_t * sf, int maxv, pointf * pts)
{
- tgraph *g;
tnode *np;
int j, i, ne = 0;
int *jp;
if (sf->neigh[i] != -1)
ne++;
- g = GNEW(tgraph);
+ tgraph *g = gv_alloc(sizeof(tgraph));
/* plus 2 for nodes added as endpoints of an edge */
g->nnodes = sf->nfaces + 2;
- g->nodes = N_GNEW(g->nnodes, tnode);
-
- g->edges = NULL;
- g->nedges = 0;
+ g->nodes = gv_calloc(g->nnodes, sizeof(tnode));
for (i = 0; i < sf->nfaces; i++) {
np = g->nodes + i;
- np->ne = 0;
- np->edges = NULL;
np->ctr = triCenter(pts, sf->faces + 3 * i);
}
- /* initialize variable nodes */
- np = g->nodes + i;
- np->ne = 0;
- np->edges = NULL;
- np++;
- np->ne = 0;
- np->edges = NULL;
for (i = 0; i < sf->nfaces; i++) {
np = g->nodes + i;