]> granicus.if.org Git - graphviz/commitdiff
Simplify gvusershape_find();
authorEmden R. Gansner <erg@research.att.com>
Tue, 25 Mar 2014 13:50:01 +0000 (09:50 -0400)
committerEmden R. Gansner <erg@research.att.com>
Tue, 25 Mar 2014 13:50:01 +0000 (09:50 -0400)
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.

lib/gvc/gvusershape.c

index c8476a5b72bbafc0eb05c77ec73f41c856cb84cc..7869a26a219e01733a989ef06028740dbb04cb2e 100644 (file)
@@ -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;