From ef7eced7a700ba12badf412e21e682b1b1c60683 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 28 Jun 2017 22:39:11 -0700 Subject: Properly clean up allocated memory at exit --- router/alc.c | 14 ++++++++++++-- router/router.c | 3 +-- router/router.h | 3 +-- 3 files changed, 14 insertions(+), 6 deletions(-) (limited to 'router') diff --git a/router/alc.c b/router/alc.c index 704aa146..87f1e3f7 100644 --- a/router/alc.c +++ b/router/alc.c @@ -240,8 +240,8 @@ static const ALCint alcMinorVersion = 1; static ATOMIC(ALCenum) LastError = ATOMIC_INIT_STATIC(ALC_NO_ERROR); -PtrIntMap DeviceIfaceMap = PTRINTMAP_STATIC_INITIALIZE; -PtrIntMap ContextIfaceMap = PTRINTMAP_STATIC_INITIALIZE; +static PtrIntMap DeviceIfaceMap = PTRINTMAP_STATIC_INITIALIZE; +static PtrIntMap ContextIfaceMap = PTRINTMAP_STATIC_INITIALIZE; typedef struct EnumeratedList { @@ -317,6 +317,16 @@ static ALint GetDriverIndexForName(const EnumeratedList *list, const ALCchar *na return -1; } +void ReleaseALC(void) +{ + ClearDeviceList(&DevicesList); + ClearDeviceList(&AllDevicesList); + ClearDeviceList(&CaptureDevicesList); + + ResetPtrIntMap(&ContextIfaceMap); + ResetPtrIntMap(&DeviceIfaceMap); +} + ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *devicename) { diff --git a/router/router.c b/router/router.c index 3adf64e2..a8a5ebbf 100644 --- a/router/router.c +++ b/router/router.c @@ -33,8 +33,7 @@ BOOL APIENTRY DllMain(HINSTANCE module, DWORD reason, void *reserved) break; case DLL_PROCESS_DETACH: - ResetPtrIntMap(&ContextIfaceMap); - ResetPtrIntMap(&DeviceIfaceMap); + ReleaseALC(); for(i = 0;i < DriverListSize;i++) { if(DriverList[i].Module) diff --git a/router/router.h b/router/router.h index 016c3998..f4ba33c7 100644 --- a/router/router.h +++ b/router/router.h @@ -135,7 +135,6 @@ ALint RemovePtrIntMapKey(PtrIntMap *map, ALvoid *key); ALint LookupPtrIntMapKey(PtrIntMap *map, ALvoid *key); -extern PtrIntMap DeviceIfaceMap; -extern PtrIntMap ContextIfaceMap; +void ReleaseALC(void); #endif /* ROUTER_ROUTER_H */ -- cgit v1.2.3