Index: src/OFDate.m ================================================================== --- src/OFDate.m +++ src/OFDate.m @@ -109,11 +109,12 @@ #if (!defined(HAVE_GMTIME_R) || !defined(HAVE_LOCALTIME_R)) && \ defined(OF_HAVE_THREADS) static OFMutex *mutex; -OF_DESTRUCTOR() +void +releaseMutex(void) { [mutex release]; } #endif @@ -349,10 +350,11 @@ placeholder.isa = [OFDatePlaceholder class]; #if (!defined(HAVE_GMTIME_R) || !defined(HAVE_LOCALTIME_R)) && \ defined(OF_HAVE_THREADS) mutex = [[OFMutex alloc] init]; + atexit(releaseMutex); #endif #ifdef OF_WINDOWS if ((module = LoadLibrary("msvcrt.dll")) != NULL) func__mktime64 = (__time64_t (*)(struct tm *)) Index: src/OFFileURLHandler.m ================================================================== --- src/OFFileURLHandler.m +++ src/OFFileURLHandler.m @@ -108,19 +108,21 @@ #endif #if defined(OF_FILE_MANAGER_SUPPORTS_OWNER) && defined(OF_HAVE_THREADS) static OFMutex *passwdMutex; -OF_DESTRUCTOR() +void +releasePasswdMutex(void) { [passwdMutex release]; } #endif #if !defined(HAVE_READDIR_R) && defined(OF_HAVE_THREADS) && !defined(OF_WINDOWS) static OFMutex *readdirMutex; -OF_DESTRUCTOR() +void +releaseReaddirMutex(void) { [readdirMutex release]; } #endif @@ -543,13 +545,15 @@ if (self != [OFFileURLHandler class]) return; #if defined(OF_FILE_MANAGER_SUPPORTS_OWNER) && defined(OF_HAVE_THREADS) passwdMutex = [[OFMutex alloc] init]; + atexit(releasePasswdMutex); #endif #if !defined(HAVE_READDIR_R) && !defined(OF_WINDOWS) && defined(OF_HAVE_THREADS) readdirMutex = [[OFMutex alloc] init]; + atexit(releaseReaddirMutex); #endif #ifdef OF_WINDOWS if ((module = LoadLibrary("msvcrt.dll")) != NULL) func__wutime64 = (int (*)(const wchar_t *, Index: src/OFURLHandler.m ================================================================== --- src/OFURLHandler.m +++ src/OFURLHandler.m @@ -35,11 +35,12 @@ static OFMutableDictionary OF_GENERIC(OFString *, OFURLHandler *) *handlers; #ifdef OF_HAVE_THREADS static OFMutex *mutex; -OF_DESTRUCTOR() +void +releaseMutex(void) { [mutex release]; } #endif @@ -52,10 +53,11 @@ return; handlers = [[OFMutableDictionary alloc] init]; #ifdef OF_HAVE_THREADS mutex = [[OFMutex alloc] init]; + atexit(releaseMutex); #endif #ifdef OF_HAVE_FILES [self registerClass: [OFFileURLHandler class] forScheme: @"file"]; Index: src/socket.m ================================================================== --- src/socket.m +++ src/socket.m @@ -54,10 +54,16 @@ # include <3ds/services/soc.h> #endif #if defined(OF_HAVE_THREADS) && (!defined(OF_AMIGAOS) || defined(OF_MORPHOS)) static OFMutex *mutex; + +static void +releaseMutex(void) +{ + [mutex release]; +} #endif #if !defined(OF_AMIGAOS) || defined(OF_MORPHOS) || !defined(OF_HAVE_THREADS) static bool initSuccessful = false; #endif @@ -123,10 +129,11 @@ atexit((void (*)(void))socExit); # endif # if defined(OF_HAVE_THREADS) && (!defined(OF_AMIGAOS) || defined(OF_MORPHOS)) mutex = [[OFMutex alloc] init]; + atexit(releaseMutex); # ifdef OF_WII if (of_spinlock_new(&spinlock) != 0) return; # endif @@ -144,12 +151,10 @@ # endif if (SocketBase != NULL) CloseLibrary(SocketBase); # endif - - [mutex release]; } #endif bool of_socket_init(void)