summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2015-05-11 11:39:46 +0000
committerKirill Volinsky <mataes2007@gmail.com>2015-05-11 11:39:46 +0000
commitd80483a71f856bbae59583799aa0e98d338f6f0b (patch)
tree4d3ea2370247c83637840469adb05afe0a867807 /src/modules
parent95bd3625cbe8e9a20b69a8a5a994b777fd5ad3a2 (diff)
minus critical section
git-svn-id: http://svn.miranda-ng.org/main/trunk@13527 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/protocols/protodir.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/modules/protocols/protodir.cpp b/src/modules/protocols/protodir.cpp
index 60f3c3a313..27626880ad 100644
--- a/src/modules/protocols/protodir.cpp
+++ b/src/modules/protocols/protodir.cpp
@@ -60,7 +60,7 @@ typedef struct {
} contactEntry;
typedef struct {
- CRITICAL_SECTION csLock;
+ mir_cs csLock;
SortedList contactCache; // index for id/proto -> hContact
SortedList protoCache; // index for hContact -> proto/id
SortedList protoNameCache; // index of protocol names
@@ -104,14 +104,13 @@ char * contactDir_Proto_Add(contactDir * cd, char * proto)
{
int index = 0 ;
char * szCache = 0;
- EnterCriticalSection(&cd->csLock);
+ mir_cslock lck(cd->csLock);
if ( List_GetIndex(&cd->protoNameCache, proto, &index) ) szCache = cd->protoNameCache.items[index];
else {
szCache = HeapAlloc(hCacheHeap, HEAP_NO_SERIALIZE, strlen(proto)+1);
strcpy(szCache, proto);
List_Insert(&cd->protoNameCache, szCache, index);
}
- LeaveCriticalSection(&cd->csLock);
return szCache;
}
@@ -124,12 +123,11 @@ char * contactDir_Proto_Get(contactDir * cd, HANDLE hContact)
e.hContact=hContact;
e.proto="";
e.id="";
- EnterCriticalSection(&cd->csLock);
+ mir_cslock lck(cd->csLock);
if ( List_GetIndex(&cd->protoCache, &e, &index) ) {
contactEntry * p = cd->protoCache.items[index];
szCache = p->proto;
}
- LeaveCriticalSection(&cd->csLock);
return szCache;
}
@@ -144,7 +142,7 @@ void contactDir_Contact_Add(contactDir * cd, HANDLE hContact, char * proto, char
e.hContact=hContact;
e.proto = proto;
e.id = "";
- EnterCriticalSection(&cd->csLock);
+ mir_cslock lck(cd->csLock);
if ( List_GetIndex(&cd->protoCache, &e, &index) ) {
contactEntry * p = cd->protoCache.items[index];
// this hContact is in the cache, protcol changing?
@@ -159,7 +157,6 @@ void contactDir_Contact_Add(contactDir * cd, HANDLE hContact, char * proto, char
// add it
List_Insert(&cd->protoCache, p, index);
}
- LeaveCriticalSection(&cd->csLock);
} else {
// this contact HAS to be in ->protoCache since it was added during startup
// need to find the contactEntry* that should already exist for it
@@ -197,7 +194,6 @@ void contactDir_Proto_Walk(contactDir * cd)
void contactDir_Init(contactDir * cd)
{
- InitializeCriticalSection(&cd->csLock);
cd->contactCache.increment=50;
cd->contactCache.sortFunc=contactCacheCompare;
cd->protoCache.increment=50;
@@ -213,7 +209,6 @@ void contactDir_Deinit(contactDir * cd)
List_Destroy(&cd->contactCache);
List_Destroy(&cd->protoCache);
List_Destroy(&cd->protoNameCache);
- DeleteCriticalSection(&cd->csLock);
}
static int contactDirGetProto(WPARAM wParam, LPARAM lParam)