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=e88fdc41fa5cec99684fdef7d7063c67a8eb917f;hp=b49cffdc2bbe5f9782927e3970ac1c2a9b45d524;hpb=2a393c134fe3fe8eb85bf818cb7ad6ae4396322a;p=evince.git diff --git a/pdf/xpdf/CMap.cc b/pdf/xpdf/CMap.cc index b49cffdc..25f3af75 100644 --- a/pdf/xpdf/CMap.cc +++ b/pdf/xpdf/CMap.cc @@ -2,15 +2,16 @@ // // CMap.cc // -// Copyright 2001-2002 Glyph & Cog, LLC +// Copyright 2001-2003 Glyph & Cog, LLC // //======================================================================== -#ifdef __GNUC__ +#include + +#ifdef USE_GCC_PRAGMAS #pragma implementation #endif -#include #include #include #include @@ -143,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) { @@ -151,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) { @@ -251,6 +258,9 @@ CMap::~CMap() { if (vector) { freeCMapVector(vector); } +#if MULTITHREADED + gDestroyMutex(&mutex); +#endif } void CMap::freeCMapVector(CMapVectorEntry *vec) { @@ -265,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; } }