From: John Ellson Date: Tue, 9 Feb 2016 18:03:15 +0000 (-0500) Subject: if Context is free then also free apis X-Git-Tag: TRAVIS_CI_BUILD_EXPERIMENTAL~48 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e84822ae1fa81a7137e404f0876e7de53b763171;p=graphviz if Context is free then also free apis --- diff --git a/lib/gvc/gvcontext.c b/lib/gvc/gvcontext.c index 7600e14ae..65c2aa341 100644 --- a/lib/gvc/gvcontext.c +++ b/lib/gvc/gvcontext.c @@ -75,6 +75,13 @@ int gvFreeContext(GVC_t * gvc) { GVG_t *gvg, *gvg_next; gvplugin_package_t *package, *package_next; + gvplugin_available_t *api, *api_next; + +#define ELEM(x) +1 + /* See gvcext.h for APIS and gvcint.h for an example usage of "+1" + to get the number of APIs. */ + unsigned int num_apis = APIS, i; +#undef ELEM emit_once_reset(); gvg_next = gvc->gvgs; @@ -95,25 +102,15 @@ int gvFreeContext(GVC_t * gvc) if (gvc->input_filenames) free(gvc->input_filenames); textfont_dict_close(gvc); - free(gvc); - return (graphviz_errors + agerrors()); -} - -GVC_t* gvCloneGVC (GVC_t * gvc0) -{ - GVC_t *gvc = zmalloc(sizeof(GVC_t)); - gvc->common = gvc0->common; - memcpy (&gvc->apis, &gvc0->apis, sizeof(gvc->apis)); - memcpy (&gvc->api, &gvc0->api, sizeof(gvc->api)); - gvc->packages = gvc->packages; - - return gvc; -} + for (i = 0; i != num_apis; ++i) { + for (api = gvc->apis[i]; api != NULL; api = api_next) { + api_next = api->next; + free(api); + } + } -void gvFreeCloneGVC (GVC_t * gvc) -{ - gvjobs_delete(gvc); free(gvc); + return (graphviz_errors + agerrors()); }