OSSP CVS Repository

ossp - Check-in [2835]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 2835
Date: 2002-Nov-18 11:23:36 (local)
2002-Nov-18 10:23:36 (UTC)
User:rse
Branch:
Comment: more memory handling cleanups
Tickets:
Inspections:
Files:
ossp-pkg/cfg/cfg_buf.c      1.7 -> 1.8     3 inserted, 1 deleted
ossp-pkg/cfg/cfg_global.h      1.1 -> 1.2     2 inserted, 0 deleted
ossp-pkg/cfg/cfg_main.c      1.8 -> 1.9     1 inserted, 0 deleted
ossp-pkg/cfg/cfg_test.c      1.10 -> 1.11     5 inserted, 8 deleted

ossp-pkg/cfg/cfg_buf.c 1.7 -> 1.8

--- cfg_buf.c    2002/11/18 09:51:29     1.7
+++ cfg_buf.c    2002/11/18 10:23:36     1.8
@@ -125,8 +125,10 @@
 {
     if (buf == NULL)
         return CFG_ERR_ARG;
-    if (ptr != NULL)
+    if (ptr != NULL) {
         *ptr  = buf->buf_ptr;
+        buf->buf_ptr = NULL;
+    }
     if (len != NULL)
         *len  = buf->buf_len;
     if (size != NULL)


ossp-pkg/cfg/cfg_global.h 1.1 -> 1.2

--- cfg_global.h 2002/11/18 09:51:29     1.1
+++ cfg_global.h 2002/11/18 10:23:36     1.2
@@ -31,6 +31,8 @@
 #ifndef __CFG_GLOBAL_H__
 #define __CFG_GLOBAL_H__
 
+#include "config.h"
+
 #ifdef WITH_DMALLOC
 #include "dmalloc.h"
 #endif


ossp-pkg/cfg/cfg_main.c 1.8 -> 1.9

--- cfg_main.c   2002/11/18 09:51:29     1.8
+++ cfg_main.c   2002/11/18 10:23:36     1.9
@@ -77,6 +77,7 @@
 {
     if (cfg == NULL)
         return CFG_ERR_ARG;
+    /* FIXME: on each node, free token string first */
     cfg_grid_destroy(cfg->grid_nodes);
     cfg_grid_destroy(cfg->grid_tokens);
     free(cfg);


ossp-pkg/cfg/cfg_test.c 1.10 -> 1.11

--- cfg_test.c   2002/11/18 09:51:29     1.10
+++ cfg_test.c   2002/11/18 10:23:36     1.11
@@ -42,24 +42,24 @@
         cfg_destroy(cfg);
         exit(1);
     }
+    free(im_ptr);
 
     if ((rc = cfg_export(cfg, NULL, CFG_FMT_CFG, &ex_ptr, 0)) != CFG_OK) {
         cfg_error(cfg, rc, &error);
         fprintf(stderr, "ERROR: cfg_export: %s\n", error);
-        free(im_ptr);
         cfg_destroy(cfg);
         exit(1);
     }
 
     fprintf(stdout, "%s", ex_ptr);
     fflush(stdout);
+    free(ex_ptr);
 
     if (argc == 3) {
         if ((rc = cfg_node_select(cfg, NULL, &vec, "%s", argv[2])) != CFG_OK) {
             cfg_error(cfg, rc, &error);
             fprintf(stderr, "ERROR: cfg_node_select: %s\n", error);
-            free(im_ptr);
-            /*cfg_destroy(cfg);*/
+            cfg_destroy(cfg);
             exit(1);
         }
         for (i = 1; vec[i] != NULL; i++) {
@@ -67,19 +67,16 @@
             if ((rc = cfg_export(cfg, vec[i], CFG_FMT_CFG, &ex_ptr, 0)) != CFG_OK) {
                 cfg_error(cfg, rc, &error);
                 fprintf(stderr, "ERROR: cfg_export: %s\n", error);
-                free(im_ptr);
-                /*cfg_destroy(cfg);*/
+                cfg_destroy(cfg);
                 exit(1);
             }
             fprintf(stdout, "%s", ex_ptr);
             fprintf(stdout, "---- selection #%d ----\n", i);
+            free(ex_ptr);
         }
     }
 
-#if 0
-    cfg_syn_destroy(cfg, node);
     cfg_destroy(cfg);
-#endif
 
     return 0;
 }

CVSTrac 2.0.1