From: Emden R. Gansner Date: Thu, 6 Jun 2013 17:53:49 +0000 (-0400) Subject: Add function to release memory allocated by gvRenderData; this avoids X-Git-Tag: LAST_LIBGRAPH~32^2~189 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b3b7e0d1aea43baa81bf06a27d38447d6958c1b8;p=graphviz Add function to release memory allocated by gvRenderData; this avoids potential conflicts with run-time functions. Also, ifdef'ed out two assignments in gvFreeLayout that are meaningless using cgraph, as the GD_drawing(g) is already gone. --- diff --git a/lib/gvc.def b/lib/gvc.def index d8161cf0b..2efcf8de8 100644 --- a/lib/gvc.def +++ b/lib/gvc.def @@ -147,6 +147,7 @@ gvputc gvputs gvRender gvRenderData +gvFreeRenderData gvRenderFilename gvRenderJobs gvToggle diff --git a/lib/gvc/gvc.c b/lib/gvc/gvc.c index 672cb4d1d..b362b07fc 100644 --- a/lib/gvc/gvc.c +++ b/lib/gvc/gvc.c @@ -252,6 +252,14 @@ int gvRenderData(GVC_t *gvc, graph_t *g, const char *format, char **result, unsi return rc; } +/* gvFreeRenderData: + * Utility routine to free memory allocated in gvRenderData, as the application code may use + * a different runtime library. + */ +void gvFreeRenderData (char* data) +{ + free (data); +} void gvAddLibrary(GVC_t *gvc, gvplugin_library_t *lib) { diff --git a/lib/gvc/gvc.h b/lib/gvc/gvc.h index 06b60011c..a60366b2c 100644 --- a/lib/gvc/gvc.h +++ b/lib/gvc/gvc.h @@ -78,6 +78,9 @@ extern int gvRenderContext(GVC_t *gvc, graph_t *g, const char *format, void *con /* Render layout in a specified format to a malloc'ed string */ extern int gvRenderData(GVC_t *gvc, graph_t *g, const char *format, char **result, unsigned int *length); +/* Free memory allocated and pointed to by *result in gvRenderData */ +extern void gvFreeRenderData (char* data); + /* Render layout according to -T and -o options found by gvParseArgs */ extern int gvRenderJobs(GVC_t *gvc, graph_t *g); diff --git a/lib/gvc/gvlayout.c b/lib/gvc/gvlayout.c index 71a4365de..70d71a2ce 100644 --- a/lib/gvc/gvlayout.c +++ b/lib/gvc/gvlayout.c @@ -119,8 +119,10 @@ int gvFreeLayout(GVC_t * gvc, Agraph_t * g) if (GD_drawing(g)) { graph_cleanup(g); +#ifndef WITH_CGRAPH GD_drawing(g) = NULL; GD_drawing(g->root) = NULL; +#endif } return 0; }