]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
conf: remove some memory leaks, still have some more
authorYehuda Sadeh <yehuda@hq.newdream.net>
Fri, 24 Apr 2009 19:43:30 +0000 (12:43 -0700)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Fri, 24 Apr 2009 19:44:43 +0000 (12:44 -0700)
src/cconf.cc
src/common/ConfUtils.cc
src/config.cc

index ee198909718260a4e78cca95b278694b1ca9eefb..c7ed7a9a33dc4a414bc0a00763bc9230ca4fd9e2 100644 (file)
@@ -111,6 +111,7 @@ int main(int argc, const char **argv)
 
 done_ok:
       cout << val << std::endl;
+      free(val);
       exit(0);
 
 }
index 61439dac3442132a64e3d0a276732df1f9513f26..6139076618e6b83f4c3c2c6d17255123a5efb156 100644 (file)
@@ -564,12 +564,16 @@ bool ConfFile::_parse(char *filename, ConfSection **psection)
                                                        printf("error parsing %s\n", cl->get_val());
                                                }
                                        } else {
-                                               section->conf_map[cl->get_norm_var()] = cl;
+                                               char *norm_var = cl->get_norm_var();
+                                               section->conf_map[norm_var] = cl;
+                                               free(norm_var);
                                                global_list.push_back(cl);
                                                section->conf_list.push_back(cl);
                                        }
                                } else if (cl->get_section()) {
                                        section = _add_section(cl->get_section(), cl);
+                               } else {
+                                       delete cl;
                                }
                                l = 0;
                                break;
index ec5831cf680589a7bb1fee38cfb39d7c99c1e50b..9e1176c41793a59dd96b97c61d4b885ca21a10ec 100644 (file)
@@ -44,6 +44,20 @@ static bool show_config = false;
 static ConfFile *cf = NULL;
 static ExportControl *ec = NULL;
 
+class ConfFileDestructor
+{
+public:
+  ConfFileDestructor() {}
+  ~ConfFileDestructor() {
+    if (cf) {
+      delete cf;
+      cf = NULL;
+    }
+  }
+};
+
+static ConfFileDestructor cfd;
+
 // page size crap, see page.h
 int _get_bits_of(int v) {
   int n = 0;