Commit fcbcf78a authored by Pekka Pessi's avatar Pekka Pessi

su_alloc_lock.c: freeing memory of mutexes when they are destroyed

darcs-hash:20070131200910-65a35-7e52523d25a1c938e5a24c30aaea11585738e7e3.gz
parent 78416d1e
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#if SU_HAVE_PTHREADS #if SU_HAVE_PTHREADS
#include <pthread.h> #include <pthread.h>
#include <assert.h> #include <assert.h>
#include <stdlib.h>
extern void (*su_home_locker)(void *mutex); extern void (*su_home_locker)(void *mutex);
extern void (*su_home_unlocker)(void *mutex); extern void (*su_home_unlocker)(void *mutex);
...@@ -66,6 +67,7 @@ static void mutex_destroy(void *_mutex) ...@@ -66,6 +67,7 @@ static void mutex_destroy(void *_mutex)
pthread_mutex_t *mutex = _mutex; pthread_mutex_t *mutex = _mutex;
pthread_mutex_destroy(mutex + 0); pthread_mutex_destroy(mutex + 0);
pthread_mutex_destroy(mutex + 1); pthread_mutex_destroy(mutex + 1);
free(_mutex);
} }
#endif #endif
...@@ -107,7 +109,7 @@ int su_home_threadsafe(su_home_t *home) ...@@ -107,7 +109,7 @@ int su_home_threadsafe(su_home_t *home)
su_home_destroy_mutexes = mutex_destroy; su_home_destroy_mutexes = mutex_destroy;
} }
mutex = su_alloc(home, 2 * sizeof (pthread_mutex_t)); mutex = calloc(1, 2 * (sizeof *mutex));
assert(mutex); assert(mutex);
if (mutex) { if (mutex) {
/* Mutex for memory operations */ /* Mutex for memory operations */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment