From: Emden R. Gansner Date: Tue, 25 Mar 2014 13:50:01 +0000 (-0400) Subject: Simplify gvusershape_find(); X-Git-Tag: 2.38.0~2^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8c1a84e23c78bc02f5d9b76f4d3d8d35343df2ea;p=graphviz Simplify gvusershape_find(); fix bug 2425. With the use of cgraph, the strings used in attributes are attached to the root graph, so file name pointers being stored in the image cache are no longer valid when the graph is deleted. The image cache needs to use the global string cache. As this could lead to many unsed image cache items, we might consider limiting the cache size, or starting afresh with each new graph. --- diff --git a/lib/gvc/gvusershape.c b/lib/gvc/gvusershape.c index c8476a5b7..7869a26a2 100644 --- a/lib/gvc/gvusershape.c +++ b/lib/gvc/gvusershape.c @@ -572,7 +572,7 @@ static Dtdisc_t ImageDictDisc = { usershape_t *gvusershape_find(char *name) { - usershape_t probe, *us; + usershape_t *us; assert(name); assert(name[0]); @@ -580,8 +580,7 @@ usershape_t *gvusershape_find(char *name) if (!ImageDict) return NULL; - probe.name = name; - us = dtsearch(ImageDict, &probe); + us = dtmatch(ImageDict, name); return us; } @@ -643,7 +642,7 @@ static usershape_t *gvusershape_open (char *name) if (! (us = zmalloc(sizeof(usershape_t)))) return NULL; - us->name = name; + us->name = agstrdup (0, name); if (!gvusershape_file_access(us)) return NULL;