diff options
author | paulo <paul@bayleaf.org.uk> | 2009-12-17 16:25:29 +0000 |
---|---|---|
committer | paulo <paul@bayleaf.org.uk> | 2009-12-17 16:25:29 +0000 |
commit | 29e6ad6c07992d6a947d739d1665a95e817e6e9b (patch) | |
tree | d86b1aa9072cab272df2addaab69e0cb2df64851 /lib/memory.c | |
parent | 57c08de786262cfb59cbc691ac18712d0ac1e9e3 (diff) | |
download | quagga-29e6ad6c07992d6a947d739d1665a95e817e6e9b.tar.bz2 quagga-29e6ad6c07992d6a947d739d1665a95e817e6e9b.tar.xz |
Use static mutexes
Diffstat (limited to 'lib/memory.c')
-rw-r--r-- | lib/memory.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/lib/memory.c b/lib/memory.c index 9bb49d18..e11a5e4a 100644 --- a/lib/memory.c +++ b/lib/memory.c @@ -32,9 +32,9 @@ /* Needs to be qpthread safe. The system malloc etc are already * thread safe, but we need to protect the stats */ -static qpt_mutex_t* memory_mutex = NULL; -#define LOCK if(memory_mutex)qpt_mutex_lock(memory_mutex); -#define UNLOCK if(memory_mutex)qpt_mutex_unlock(memory_mutex); +static qpt_mutex_t memory_mutex; +#define LOCK qpt_mutex_lock(&memory_mutex); +#define UNLOCK qpt_mutex_unlock(&memory_mutex); static void alloc_inc (int); static void alloc_dec (int); @@ -516,20 +516,14 @@ DEFUN_CALL (show_memory_isis, void memory_init_r (void) { - memory_mutex = qpt_mutex_init(memory_mutex, qpt_mutex_quagga); + qpt_mutex_init(&memory_mutex, qpt_mutex_quagga); } /* Finished with module */ void memory_finish (void) { - if (memory_mutex) - { - /* avoid re-entrancy with memory disposal */ - qpt_mutex_t* mx = memory_mutex; - memory_mutex = NULL; - qpt_mutex_destroy(mx, 1); - } + qpt_mutex_destroy(&memory_mutex, 0); } void |