diff options
author | Arch Librarian <arch@canonical.com> | 2004-09-20 16:59:17 +0000 |
---|---|---|
committer | Arch Librarian <arch@canonical.com> | 2004-09-20 16:59:17 +0000 |
commit | 1c193e02ec0d090eeae62f371b2942e74dab48b1 (patch) | |
tree | a924136f6434fcf88d565fef2970934e3fa1c908 | |
parent | f5ec3b68c582138acce7c5a93e473dde50ab8354 (diff) |
Fix small memory leak in the sourcelist
Author: jgg
Date: 2002-07-01 21:41:11 GMT
Fix small memory leak in the sourcelist
-rw-r--r-- | apt-pkg/sourcelist.cc | 21 | ||||
-rw-r--r-- | apt-pkg/sourcelist.h | 5 |
2 files changed, 23 insertions, 3 deletions
diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index cb1287623..1173098d2 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: sourcelist.cc,v 1.22 2002/03/26 07:38:58 jgg Exp $ +// $Id: sourcelist.cc,v 1.23 2002/07/01 21:41:11 jgg Exp $ /* ###################################################################### List of Sources @@ -128,6 +128,18 @@ pkgSourceList::pkgSourceList(string File) Read(File); } /*}}}*/ +// SourceList::~pkgSourceList - Destructor /*{{{*/ +// --------------------------------------------------------------------- +/* */ +pkgSourceList::~pkgSourceList() +{ + for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++) + delete *I; + for (vector<Vendor const *>::const_iterator I = VendorList.begin(); + I != VendorList.end(); I++) + delete *I; +} + /*}}}*/ // SourceList::ReadVendors - Read list of known package vendors /*{{{*/ // --------------------------------------------------------------------- /* This also scans a directory of vendor files similar to apt.conf.d @@ -147,6 +159,11 @@ bool pkgSourceList::ReadVendors() if (ReadConfigFile(Cnf,CnfFile,true) == false) return false; + for (vector<Vendor const *>::const_iterator I = VendorList.begin(); + I != VendorList.end(); I++) + delete *I; + VendorList.erase(VendorList.begin(),VendorList.end()); + // Process 'simple-key' type sections const Configuration::Item *Top = Cnf.Tree("simple-key"); for (Top = (Top == 0?0:Top->Child); Top != 0; Top = Top->Next) @@ -217,6 +234,8 @@ bool pkgSourceList::Read(string File) if (!F != 0) return _error->Errno("ifstream::ifstream",_("Opening %s"),File.c_str()); + for (const_iterator I = SrcList.begin(); I != SrcList.end(); I++) + delete *I; SrcList.erase(SrcList.begin(),SrcList.end()); char Buffer[300]; diff --git a/apt-pkg/sourcelist.h b/apt-pkg/sourcelist.h index 8e0cb7aa3..307b12133 100644 --- a/apt-pkg/sourcelist.h +++ b/apt-pkg/sourcelist.h @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: sourcelist.h,v 1.11 2001/05/07 04:24:08 jgg Exp $ +// $Id: sourcelist.h,v 1.12 2002/07/01 21:41:11 jgg Exp $ /* ###################################################################### SourceList - Manage a list of sources @@ -106,7 +106,8 @@ class pkgSourceList bool GetIndexes(pkgAcquire *Owner) const; pkgSourceList(); - pkgSourceList(string File); + pkgSourceList(string File); + ~pkgSourceList(); }; #endif |