]> granicus.if.org Git - graphviz/commitdiff
tidy gv_argvlist_t code
authorellson <devnull@localhost>
Tue, 18 Oct 2005 18:49:48 +0000 (18:49 +0000)
committerellson <devnull@localhost>
Tue, 18 Oct 2005 18:49:48 +0000 (18:49 +0000)
lib/common/memory.h
lib/gvc/gvcproc.h
lib/gvc/gvevent.c
lib/gvc/gvjobs.c

index cfd7717617855c8a65aad7d5c3dcbbc132be78dc..1e575e1bd800938adff068a7a12c00411a2c8454 100644 (file)
@@ -17,6 +17,8 @@
 #ifndef GV_MEMORY_H
 #define GV_MEMORY_H
 
+#include <malloc.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
index 3ae29f65abf6a5533d7aa28c00b1f6e5609fd77f..8f44bbd49713e57c035193bb0d7216d97145a973 100644 (file)
@@ -124,6 +124,12 @@ extern "C" {
     extern int gvFreeLayout(GVC_t * gvc, graph_t * g);
     extern int gvLayoutJobs(GVC_t * gvc, graph_t * g);
 
+/* argvlist */
+    extern gv_argvlist_t *gvNEWargvlist(void);
+    extern void gv_argvlist_set_item(gv_argvlist_t *list, int index, char *item);
+    extern void gv_argvlist_reset(gv_argvlist_t *list);
+    extern void gv_argvlist_free(gv_argvlist_t *list);
+
 #ifdef __cplusplus
 }
 #endif
index 3a2f52aa9cac8e8207a88a8eb1bf4027c9ed2a72..6a682913aaf098db1d8feb23998c412ae942eb54 100644 (file)
@@ -35,16 +35,6 @@ static char *s_tailport = "tailport";
 static char *s_headport = "headport";
 static char *s_key = "key";
 
-/* FIXME - gv_argvlist_set_item and gv_argvlist_free should be in a utilities sourcefile */
-static void gv_argvlist_set_item(gv_argvlist_t *list, int index, char *item)
-{
-    if (index >= list->alloc) {
-       list->alloc = index + 10;
-       list->argv = realloc(list->argv, (list->alloc)*(sizeof(char*)));
-    }
-    list->argv[index] = item;
-}
-
 static void gv_graph_state(GVJ_t *job, graph_t *g)
 {
     int i, j;
index d6f36abb007da7fc6c0b1f4b8b54a3b77d985c74..85b8d3f4d2e6d3dae9b4a041d785801f91e17afc 100644 (file)
@@ -22,6 +22,7 @@
 #include       <stdlib.h>
 
 #include       "geom.h"
+#include       "memory.h"
 
 #include       "types.h"
 
@@ -29,9 +30,6 @@
 #include        "gvcint.h"
 #include        "gvcproc.h"
 
-/* from common/utils.c */
-extern void *zmalloc(size_t);
-
 static GVJ_t *output_filename_job;
 static GVJ_t *output_langname_job;
 
@@ -118,8 +116,21 @@ GVJ_t *gvrender_next_job(GVC_t * gvc)
     return (gvc->job = job);
 }
 
-/* FIXME - gv_argvlist_set_item and gv_argvlist_free should be in a utilities sourcefile */
-static void gv_argvlist_free(gv_argvlist_t *list)
+gv_argvlist_t *gvNEWargvlist(void)
+{
+    return (gv_argvlist_t*)zmalloc(sizeof(gv_argvlist_t));
+}
+
+void gv_argvlist_set_item(gv_argvlist_t *list, int index, char *item)
+{
+    if (index >= list->alloc) {
+       list->alloc = index + 10;
+       list->argv = grealloc(list->argv, (list->alloc)*(sizeof(char*)));
+    }
+    list->argv[index] = item;
+}
+
+void gv_argvlist_reset(gv_argvlist_t *list)
 {
     if (list->argv)
        free(list->argv);
@@ -128,6 +139,13 @@ static void gv_argvlist_free(gv_argvlist_t *list)
     list->argc = 0;
 }
 
+void gv_argvlist_free(gv_argvlist_t *list)
+{
+    if (list->argv)
+       free(list->argv);
+    free(list);
+}
+
 void gvrender_delete_jobs(GVC_t * gvc)
 {
     GVJ_t *job, *j;
@@ -135,8 +153,8 @@ void gvrender_delete_jobs(GVC_t * gvc)
     job = gvc->jobs;
     while ((j = job)) {
        job = job->next;
-       gv_argvlist_free(&(j->selected_obj_attributes));
-       gv_argvlist_free(&(j->selected_obj_type_name));
+       gv_argvlist_reset(&(j->selected_obj_attributes));
+       gv_argvlist_reset(&(j->selected_obj_type_name));
        if (j->active_tooltip)
            free(j->active_tooltip);
        if (j->selected_href)