summaryrefslogtreecommitdiff
path: root/plugins/CountryFlags/src/ip2country.cpp
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2015-04-30 19:02:32 +0000
committerKirill Volinsky <mataes2007@gmail.com>2015-04-30 19:02:32 +0000
commitc2d108fafa96b9dbe03ad4bba6cf2a72afa2afde (patch)
tree65a1dc0fdddb5ca4940b170cc0a95942d842f62f /plugins/CountryFlags/src/ip2country.cpp
parent52ace5d0ddf05c78c282fb1df714eddd73c4e7e3 (diff)
minus critical section
git-svn-id: http://svn.miranda-ng.org/main/trunk@13305 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/CountryFlags/src/ip2country.cpp')
-rw-r--r--plugins/CountryFlags/src/ip2country.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/plugins/CountryFlags/src/ip2country.cpp b/plugins/CountryFlags/src/ip2country.cpp
index e233fbbf17..76976594ba 100644
--- a/plugins/CountryFlags/src/ip2country.cpp
+++ b/plugins/CountryFlags/src/ip2country.cpp
@@ -52,7 +52,7 @@ static int GetDataRecord(BYTE *data,DWORD index,DWORD *pdwFrom,DWORD *pdwTo)
/************************* Record Cache ***************************/
-static CRITICAL_SECTION csRecordCache;
+static mir_cs csRecordCache;
static DWORD nDataRecordsCount; /* protected by csRecordCache */
static BYTE *dataRecords; /* protected by csRecordCache */
@@ -60,10 +60,9 @@ static BYTE *dataRecords; /* protected by csRecordCache */
static void CALLBACK UnloadRecordCache(LPARAM)
{
- EnterCriticalSection(&csRecordCache);
+ mir_cslock lck(csRecordCache);
mir_free(dataRecords);
dataRecords=NULL;
- LeaveCriticalSection(&csRecordCache);
}
// function assumes it has got the csRecordCache mutex
@@ -71,16 +70,18 @@ static BOOL EnsureRecordCacheLoaded(BYTE **pdata,DWORD *pcount)
{
HRSRC hrsrc;
DWORD cb;
- EnterCriticalSection(&csRecordCache);
+ mir_cslock lck(csRecordCache);
if (dataRecords == NULL) {
/* load record data list from resources */
hrsrc=FindResource(hInst,MAKEINTRESOURCE(IDR_IPTOCOUNTRY),_T("BIN"));
cb=SizeofResource(hInst,hrsrc);
dataRecords=(BYTE*)LockResource(LoadResource(hInst,hrsrc));
- if (cb<=sizeof(DWORD) || dataRecords == NULL) { LeaveCriticalSection(&csRecordCache); return FALSE; }
+ if (cb<=sizeof(DWORD) || dataRecords == NULL)
+ return FALSE;
/* uncompress record data */
dataRecords=GetDataHeader(dataRecords,cb,&nDataRecordsCount);
- if (dataRecords == NULL || !nDataRecordsCount) { LeaveCriticalSection(&csRecordCache); return FALSE; }
+ if (dataRecords == NULL || !nDataRecordsCount)
+ return FALSE;
}
*pdata=dataRecords;
*pcount=nDataRecordsCount;
@@ -91,7 +92,6 @@ static void LeaveRecordCache(void)
{
/* mark for unload */
CallFunctionBuffered(UnloadRecordCache,0,FALSE,UNLOADDELAY);
- LeaveCriticalSection(&csRecordCache);
}
/************************* Services *******************************/
@@ -301,8 +301,6 @@ static void BinConvThread(void *unused)
void InitIpToCountry(void)
{
- /* Record Cache */
- InitializeCriticalSection(&csRecordCache);
nDataRecordsCount=0;
dataRecords=NULL;
/* Services */
@@ -314,8 +312,6 @@ void InitIpToCountry(void)
void UninitIpToCountry(void)
{
- /* Record Cache */
- DeleteCriticalSection(&csRecordCache);
mir_free(dataRecords); /* does NULL check */
/* Servcies */
DestroyServiceFunction(hServiceIpToCountry);