summaryrefslogtreecommitdiff
path: root/fofi
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2018-09-23 01:16:43 +0200
committerAlbert Astals Cid <aacid@kde.org>2018-09-23 01:16:43 +0200
commit735d234d76b31c7d2061f70d0cf88cc122613a80 (patch)
tree9b21943ea0c4b5941146e82004c9cd943380126b /fofi
parentbddcc771de9e7d0a7a077732f15a958a44794f94 (diff)
FoFiBase: No need to store two pointers
that point to the same place And also make the data const (until the moment we have to free it)
Diffstat (limited to 'fofi')
-rw-r--r--fofi/FoFiBase.cc6
-rw-r--r--fofi/FoFiBase.h5
-rw-r--r--fofi/FoFiType1.cc4
3 files changed, 7 insertions, 8 deletions
diff --git a/fofi/FoFiBase.cc b/fofi/FoFiBase.cc
index abd0d5db..8ca381b3 100644
--- a/fofi/FoFiBase.cc
+++ b/fofi/FoFiBase.cc
@@ -38,15 +38,15 @@
// FoFiBase
//------------------------------------------------------------------------
-FoFiBase::FoFiBase(char *fileA, int lenA, GBool freeFileDataA) {
- fileData = file = (Guchar *)fileA;
+FoFiBase::FoFiBase(const char *fileA, int lenA, GBool freeFileDataA) {
+ file = (const Guchar *)fileA;
len = lenA;
freeFileData = freeFileDataA;
}
FoFiBase::~FoFiBase() {
if (freeFileData) {
- gfree(fileData);
+ gfree((char*)file);
}
}
diff --git a/fofi/FoFiBase.h b/fofi/FoFiBase.h
index a34acc7e..e3413b10 100644
--- a/fofi/FoFiBase.h
+++ b/fofi/FoFiBase.h
@@ -46,7 +46,7 @@ public:
protected:
- FoFiBase(char *fileA, int lenA, GBool freeFileDataA);
+ FoFiBase(const char *fileA, int lenA, GBool freeFileDataA);
static char *readFile(const char *fileName, int *fileLen);
// S = signed / U = unsigned
@@ -63,8 +63,7 @@ protected:
GBool checkRegion(int pos, int size) const;
- Guchar *fileData;
- Guchar *file;
+ const Guchar *file;
int len;
GBool freeFileData;
};
diff --git a/fofi/FoFiType1.cc b/fofi/FoFiType1.cc
index 14fd5109..a5d73e0e 100644
--- a/fofi/FoFiType1.cc
+++ b/fofi/FoFiType1.cc
@@ -395,9 +395,9 @@ void FoFiType1::undoPFB() {
pos2 += segLen;
}
if (freeFileData) {
- gfree(fileData);
+ gfree((char*)file);
}
- file = fileData = file2;
+ file = file2;
freeFileData = gTrue;
len = pos2;
}