static long myiddisc_map(void *state, int objtype, char *str, unsigned long *id, int createflag) { gctx_t *gctx = (gctx_t *)state; ictx_t *ictx = gctx->ictx; char *s; if (str) { if (createflag) s = agstrdup(gctx->g, str); else s = agstrbind(gctx->g, str); *id = (unsigned long) s; } else { *id = ictx->ctr; /* counter maintained in per-interp space, so that ids are unique across all graphs in the interp */ ictx->ctr += 2; } return TRUE; }
static long idmap(void *state, int objtype, char *str, unsigned long *id, int createflag) { char *s; static unsigned long ctr = 1; NOTUSED(objtype); if (str) { Agraph_t *g; g = state; if (createflag) s = agstrdup(g, str); else s = agstrbind(g, str); *id = (unsigned long) s; } else { *id = ctr; ctr += 2; } return TRUE; }