X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=pdf%2Fxpdf%2FCMap.cc;h=25f3af75e7066d81c3a5dc7ffb22d1cc3860cbaf;hb=f75141348caac3ba34ff3b3d8420215386f0eb02;hp=c60ce3c3761338d57e7e779eafc35cb5b2e185a3;hpb=7c5ab64d4db75e4bb6dadedb578e10178554d0db;p=evince.git diff --git a/pdf/xpdf/CMap.cc b/pdf/xpdf/CMap.cc index c60ce3c3..25f3af75 100644 --- a/pdf/xpdf/CMap.cc +++ b/pdf/xpdf/CMap.cc @@ -144,6 +144,9 @@ CMap::CMap(GString *collectionA, GString *cMapNameA) { vector[i].cid = 0; } refCnt = 1; +#if MULTITHREADED + gInitMutex(&mutex); +#endif } CMap::CMap(GString *collectionA, GString *cMapNameA, int wModeA) { @@ -152,6 +155,9 @@ CMap::CMap(GString *collectionA, GString *cMapNameA, int wModeA) { wMode = wModeA; vector = NULL; refCnt = 1; +#if MULTITHREADED + gInitMutex(&mutex); +#endif } void CMap::useCMap(CMapCache *cache, char *useName) { @@ -252,6 +258,9 @@ CMap::~CMap() { if (vector) { freeCMapVector(vector); } +#if MULTITHREADED + gDestroyMutex(&mutex); +#endif } void CMap::freeCMapVector(CMapVectorEntry *vec) { @@ -266,11 +275,26 @@ void CMap::freeCMapVector(CMapVectorEntry *vec) { } void CMap::incRefCnt() { +#if MULTITHREADED + gLockMutex(&mutex); +#endif ++refCnt; +#if MULTITHREADED + gUnlockMutex(&mutex); +#endif } void CMap::decRefCnt() { - if (--refCnt == 0) { + GBool done; + +#if MULTITHREADED + gLockMutex(&mutex); +#endif + done = --refCnt == 0; +#if MULTITHREADED + gUnlockMutex(&mutex); +#endif + if (done) { delete this; } }