diff options
Diffstat (limited to 'apt-pkg/deb/debindexfile.cc')
-rw-r--r-- | apt-pkg/deb/debindexfile.cc | 42 |
1 files changed, 12 insertions, 30 deletions
diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc index c55847305..6aa3af162 100644 --- a/apt-pkg/deb/debindexfile.cc +++ b/apt-pkg/deb/debindexfile.cc @@ -11,23 +11,23 @@ // Include Files /*{{{*/ #include <config.h> +#include <apt-pkg/configuration.h> #include <apt-pkg/debindexfile.h> -#include <apt-pkg/debsrcrecords.h> #include <apt-pkg/deblistparser.h> #include <apt-pkg/debrecords.h> -#include <apt-pkg/configuration.h> +#include <apt-pkg/debsrcrecords.h> #include <apt-pkg/error.h> #include <apt-pkg/fileutl.h> #include <apt-pkg/indexfile.h> #include <apt-pkg/pkgcache.h> -#include <apt-pkg/cacheiterators.h> #include <apt-pkg/pkgrecords.h> #include <apt-pkg/srcrecords.h> -#include <stdio.h> #include <iostream> -#include <string> +#include <memory> #include <sstream> +#include <string> +#include <stdio.h> #include <sys/stat.h> #include <unistd.h> @@ -66,7 +66,7 @@ bool debSourcesIndex::OpenListFile(FileFd &, std::string const &) } pkgCacheListParser * debSourcesIndex::CreateListParser(FileFd &) { - return NULL; + return nullptr; } uint8_t debSourcesIndex::GetIndexFlags() const { @@ -128,16 +128,10 @@ pkgCacheListParser * debTranslationsIndex::CreateListParser(FileFd &Pkg) if (Pkg.IsOpen() == false) return nullptr; _error->PushToStack(); - pkgCacheListParser * const Parser = new debTranslationsParser(&Pkg); + std::unique_ptr<pkgCacheListParser> Parser(new debTranslationsParser(&Pkg)); bool const newError = _error->PendingError(); _error->MergeWithStack(); - if (newError) - { - delete Parser; - return nullptr; - } - else - return Parser; + return newError ? nullptr : Parser.release(); } /*}}}*/ // dpkg/status Index /*{{{*/ @@ -162,16 +156,10 @@ pkgCacheListParser * debStatusIndex::CreateListParser(FileFd &Pkg) if (Pkg.IsOpen() == false) return nullptr; _error->PushToStack(); - pkgCacheListParser * const Parser = new debStatusListParser(&Pkg); + std::unique_ptr<pkgCacheListParser> Parser(new debStatusListParser(&Pkg)); bool const newError = _error->PendingError(); _error->MergeWithStack(); - if (newError) - { - delete Parser; - return nullptr; - } - else - return Parser; + return newError ? nullptr : Parser.release(); } /*}}}*/ // DebPkgFile Index - a single .deb file as an index /*{{{*/ @@ -244,16 +232,10 @@ pkgCacheListParser * debDebPkgFileIndex::CreateListParser(FileFd &Pkg) if (Pkg.IsOpen() == false) return nullptr; _error->PushToStack(); - pkgCacheListParser * const Parser = new debDebFileParser(&Pkg, DebFile); + std::unique_ptr<pkgCacheListParser> Parser(new debDebFileParser(&Pkg, DebFile)); bool const newError = _error->PendingError(); _error->MergeWithStack(); - if (newError) - { - delete Parser; - return nullptr; - } - else - return Parser; + return newError ? nullptr : Parser.release(); } uint8_t debDebPkgFileIndex::GetIndexFlags() const { |