diff options
author | George Hazan <ghazan@miranda.im> | 2019-03-12 12:40:25 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-03-12 12:40:25 +0300 |
commit | 4b4c9d139f15b208cd0f0008d2bf81f21d462232 (patch) | |
tree | 1ef10088f0a006fa9764d98fe5e304825af9169b | |
parent | ba08cda99e0127fabc21a864883e63fec1b88df4 (diff) |
another manual critical section removed
-rw-r--r-- | src/mir_core/src/miranda.h | 6 | ||||
-rw-r--r-- | src/mir_core/src/modules.cpp | 13 |
2 files changed, 6 insertions, 13 deletions
diff --git a/src/mir_core/src/miranda.h b/src/mir_core/src/miranda.h index bd83beeea1..a62d879270 100644 --- a/src/mir_core/src/miranda.h +++ b/src/mir_core/src/miranda.h @@ -64,15 +64,15 @@ struct THookSubscriber #define HOOK_SECRET_SIGNATURE 0xDEADBABA
-struct THook
+struct THook : public MZeroedObject
{
char name[ MAXMODULELABELLENGTH ];
int id;
int subscriberCount;
THookSubscriber* subscriber;
MIRANDAHOOK pfnHook;
- DWORD secretSignature;
- CRITICAL_SECTION csHook;
+ DWORD secretSignature = HOOK_SECRET_SIGNATURE;
+ mir_cs csHook;
};
extern LIST<CMPluginBase> pluginListAddr;
diff --git a/src/mir_core/src/modules.cpp b/src/mir_core/src/modules.cpp index d73b8124b7..fa900e7832 100644 --- a/src/mir_core/src/modules.cpp +++ b/src/mir_core/src/modules.cpp @@ -114,14 +114,9 @@ MIR_CORE_DLL(HANDLE) CreateHookableEvent(const char *name) if ((idx = hooks.getIndex((THook*)name)) != -1) return hooks[idx]; - THook *newItem = (THook*)mir_alloc(sizeof(THook)); + THook *newItem = new THook(); strncpy(newItem->name, name, sizeof(newItem->name)); newItem->name[MAXMODULELABELLENGTH - 1] = 0; newItem->id = sttHookId++; - newItem->subscriberCount = 0; - newItem->subscriber = nullptr; - newItem->pfnHook = nullptr; - newItem->secretSignature = HOOK_SECRET_SIGNATURE; - InitializeCriticalSection(&newItem->csHook); hooks.insert(newItem); return (HANDLE)newItem; } @@ -145,8 +140,7 @@ MIR_CORE_DLL(int) DestroyHookableEvent(HANDLE hEvent) p->subscriberCount = 0; } hooks.remove(idx); - DeleteCriticalSection(&p->csHook); - mir_free(p); + delete p; return 0; } @@ -483,8 +477,7 @@ static void DestroyHooks() for (auto &it : hooks) { if (it->subscriberCount) mir_free(it->subscriber); - DeleteCriticalSection(&it->csHook); - mir_free(it); + delete it; } } |