X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;ds=sidebyside;f=pdf%2Fxpdf%2FCMap.cc;h=25f3af75e7066d81c3a5dc7ffb22d1cc3860cbaf;hb=9e920bcf5162b7f187cd3ed5026baa2bd155631c;hp=b00021835342d1736b41e41d574023e42ec4bbe1;hpb=28c37dbcf87665a4ccec58bef9ef8ff0697022dd;p=evince.git diff --git a/pdf/xpdf/CMap.cc b/pdf/xpdf/CMap.cc index b0002183..25f3af75 100644 --- a/pdf/xpdf/CMap.cc +++ b/pdf/xpdf/CMap.cc @@ -2,7 +2,7 @@ // // CMap.cc // -// Copyright 2001-2002 Glyph & Cog, LLC +// Copyright 2001-2003 Glyph & Cog, LLC // //======================================================================== @@ -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; } }