summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Sander <oliver.sander@tu-dresden.de>2019-10-29 10:25:59 +0100
committerAlbert Astals Cid <tsdgeos@yahoo.es>2019-11-07 13:41:25 +0000
commitd1f627fefd6dc84bd37064a421fc0095dbfd21c0 (patch)
tree9f3bc8b9418ac3449f1c4f465f747b5f0d369223
parentd89faa0f8ceddb81fc4430dec08023ac987ad0e4 (diff)
Use std::string for the filename
... and create it on the stack rather than on the heap. Makes the code more readable.
-rw-r--r--utils/pdffonts.cc15
1 files changed, 7 insertions, 8 deletions
diff --git a/utils/pdffonts.cc b/utils/pdffonts.cc
index 87ea9e0b..b940d6ac 100644
--- a/utils/pdffonts.cc
+++ b/utils/pdffonts.cc
@@ -33,6 +33,7 @@
#include <stddef.h>
#include <string.h>
#include <math.h>
+#include <string>
#include "parseargs.h"
#include "goo/GooString.h"
#include "goo/gmem.h"
@@ -92,7 +93,6 @@ static const ArgDesc argDesc[] = {
int main(int argc, char *argv[]) {
PDFDoc *doc;
- GooString *fileName;
GooString *ownerPW, *userPW;
bool ok;
int exitCode;
@@ -113,7 +113,11 @@ int main(int argc, char *argv[]) {
exitCode = 0;
return exitCode;
}
- fileName = new GooString(argv[1]);
+
+ std::string fileName(argv[1]);
+ if (fileName == "-") {
+ fileName = "fd://0";
+ }
// read config file
globalParams = new GlobalParams();
@@ -129,13 +133,8 @@ int main(int argc, char *argv[]) {
} else {
userPW = nullptr;
}
- if (fileName->cmp("-") == 0) {
- delete fileName;
- fileName = new GooString("fd://0");
- }
- doc = PDFDocFactory().createPDFDoc(*fileName, ownerPW, userPW);
- delete fileName;
+ doc = PDFDocFactory().createPDFDoc(GooString(fileName), ownerPW, userPW);
if (userPW) {
delete userPW;