From: Yehuda Sadeh Date: Fri, 24 Apr 2009 19:43:30 +0000 (-0700) Subject: conf: remove some memory leaks, still have some more X-Git-Tag: v0.7.3~54 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=84c55ed956cf38f4265f92f3d0b9016fe4cd9bec;p=ceph.git conf: remove some memory leaks, still have some more --- diff --git a/src/cconf.cc b/src/cconf.cc index ee1989097182..c7ed7a9a33dc 100644 --- a/src/cconf.cc +++ b/src/cconf.cc @@ -111,6 +111,7 @@ int main(int argc, const char **argv) done_ok: cout << val << std::endl; + free(val); exit(0); } diff --git a/src/common/ConfUtils.cc b/src/common/ConfUtils.cc index 61439dac3442..6139076618e6 100644 --- a/src/common/ConfUtils.cc +++ b/src/common/ConfUtils.cc @@ -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; diff --git a/src/config.cc b/src/config.cc index ec5831cf6805..9e1176c41793 100644 --- a/src/config.cc +++ b/src/config.cc @@ -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;