diff options
author | Oliver Sander <oliver.sander@tu-dresden.de> | 2019-10-29 10:30:19 +0100 |
---|---|---|
committer | Albert Astals Cid <tsdgeos@yahoo.es> | 2019-11-07 13:41:25 +0000 |
commit | f37f1565c0aa4efec2eaa912397f61952f5c3c7d (patch) | |
tree | 0e70453fbe8dd463522b9759e7a4e645f8bdae2b | |
parent | d1f627fefd6dc84bd37064a421fc0095dbfd21c0 (diff) |
Use std::unique_ptr for PDFDoc
-rw-r--r-- | utils/pdffonts.cc | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/utils/pdffonts.cc b/utils/pdffonts.cc index b940d6ac..652a7759 100644 --- a/utils/pdffonts.cc +++ b/utils/pdffonts.cc @@ -33,6 +33,7 @@ #include <stddef.h> #include <string.h> #include <math.h> +#include <memory> #include <string> #include "parseargs.h" #include "goo/GooString.h" @@ -92,7 +93,6 @@ static const ArgDesc argDesc[] = { }; int main(int argc, char *argv[]) { - PDFDoc *doc; GooString *ownerPW, *userPW; bool ok; int exitCode; @@ -134,7 +134,7 @@ int main(int argc, char *argv[]) { userPW = nullptr; } - doc = PDFDocFactory().createPDFDoc(GooString(fileName), ownerPW, userPW); + auto doc = std::unique_ptr<PDFDoc>(PDFDocFactory().createPDFDoc(GooString(fileName), ownerPW, userPW)); if (userPW) { delete userPW; @@ -163,7 +163,7 @@ int main(int argc, char *argv[]) { // get the fonts { - FontInfoScanner scanner(doc, firstPage - 1); + FontInfoScanner scanner(doc.get(), firstPage - 1); const std::vector<FontInfo*> fonts = scanner.scan(lastPage - firstPage + 1); if (showSubst) { @@ -212,7 +212,6 @@ int main(int argc, char *argv[]) { exitCode = 0; err1: - delete doc; delete globalParams; return exitCode; |