From: erg Date: Thu, 8 Nov 2007 21:41:21 +0000 (+0000) Subject: Change semantics of agnameof() so that NULL is returned for anonymous edges. X-Git-Tag: LAST_LIBGRAPH~32^2~5049 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2dcc9bacb34d120cef815eb6c4cc06d82d5da959;p=graphviz Change semantics of agnameof() so that NULL is returned for anonymous edges. --- diff --git a/lib/cgraph/id.c b/lib/cgraph/id.c index 59d031660..3121962ee 100644 --- a/lib/cgraph/id.c +++ b/lib/cgraph/id.c @@ -129,6 +129,12 @@ void agfreeid(Agraph_t * g, int objtype, unsigned long id) (AGDISC(g, id)->free) (AGCLOS(g, id), objtype, id); } +/* agnameof: + * Return string representation of object. + * In general, returns the name of node or graph, + * and the key of an edge. If edge is anonymous, returns NULL. + * Uses static buffer for anonymous graphs. + */ char *agnameof(void *obj) { Agraph_t *g; @@ -145,9 +151,11 @@ char *agnameof(void *obj) AGDISC(g, id)->print(AGCLOS(g, id), AGTYPE(obj), AGID(obj)))) return rv; } - if (AGTYPE(obj) != AGEDGE) + if (AGTYPE(obj) != AGEDGE) { sprintf(buf, "%c%ld", LOCALNAMEPREFIX, AGID(obj)); + rv = buf; + } else - buf[0] = 0; - return buf; + rv = 0; + return rv; }