From a25894d4ea07e349960c34f8c1222cf58dd8b530 Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Wed, 19 Jun 2013 20:12:59 -0400 Subject: [PATCH] Remove libpth2 conditionals from mem.c. --- src/cache.c | 2 +- src/mem.c | 67 +------------------------------------------------------------ 2 files changed, 2 insertions(+), 67 deletions(-) diff --git a/src/cache.c b/src/cache.c index 5a01b8f5..c4cf8407 100644 --- a/src/cache.c +++ b/src/cache.c @@ -559,7 +559,7 @@ cache_get_grip (const unsigned char *md5file, unsigned char *grip) return 1; } -/* The with_pkcs parameter is needed to prevent clearing gpg-agent +/* The atfork parameter is needed to prevent clearing gpg-agent cached keys during an atfork callback since the agent is still shared between the two processes. */ void diff --git a/src/mem.c b/src/mem.c index bfd27193..60d9ed57 100644 --- a/src/mem.c +++ b/src/mem.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "memzero.h" @@ -59,12 +60,6 @@ #include "mem.h" -#ifdef USE_PTH_THREADS -#include -#else -#include -#endif - #ifndef _ #define _ gettext(msgid) #endif @@ -77,11 +72,7 @@ struct memlist_s }; static struct memlist_s *memlist; -#ifdef USE_PTH_THREADS -static pth_mutex_t mem_mutex; -#else static pthread_mutex_t mem_mutex; -#endif #ifdef DEBUG static size_t allocations, deallocations; #endif @@ -92,11 +83,7 @@ xmem_init () static int init; if (!init) -#ifdef USE_PTH_THREADS - pth_mutex_init (&mem_mutex); -#else pthread_mutex_init (&mem_mutex, NULL); -#endif init = 1; } @@ -106,11 +93,7 @@ memlist_remove (void *ptr, const char *func) { struct memlist_s *m, *last = NULL, *p; -#ifdef USE_PTH_THREADS - pth_mutex_acquire (&mem_mutex, 0, NULL); -#else pthread_mutex_lock (&mem_mutex); -#endif for (m = memlist; m; m = m->next) { @@ -133,43 +116,27 @@ memlist_remove (void *ptr, const char *func) else memlist = p; -#ifdef USE_PTH_THREADS - pth_mutex_release (&mem_mutex); -#else pthread_mutex_unlock (&mem_mutex); -#endif return 1; } last = m; } -#ifdef USE_PTH_THREADS - pth_mutex_release (&mem_mutex); -#else pthread_mutex_unlock (&mem_mutex); -#endif return 0; } static void memlist_prepend (struct memlist_s *new) { -#ifdef USE_PTH_THREADS - pth_mutex_acquire (&mem_mutex, 0, NULL); -#else pthread_mutex_lock (&mem_mutex); -#endif #ifdef DEBUG allocations++; #endif new->next = memlist; memlist = new; -#ifdef USE_PTH_THREADS - pth_mutex_release (&mem_mutex); -#else pthread_mutex_unlock (&mem_mutex); -#endif } void @@ -250,11 +217,7 @@ xrealloc (void *ptr, size_t size) if (!ptr) return xmalloc (size); -#ifdef USE_PTH_THREADS - pth_mutex_acquire (&mem_mutex, 0, NULL); -#else pthread_mutex_lock (&mem_mutex); -#endif for (m = memlist; m; m = m->next) { @@ -262,11 +225,7 @@ xrealloc (void *ptr, size_t size) { if ((p = (void *) malloc (size)) == NULL) { -#ifdef USE_PTH_THREADS - pth_mutex_release (&mem_mutex); -#else pthread_mutex_unlock (&mem_mutex); -#endif return NULL; } @@ -279,21 +238,13 @@ xrealloc (void *ptr, size_t size) fprintf (stderr, "%s: %p %i\n", __FUNCTION__, p, size); BACKTRACE (__FUNCTION__); #endif -#ifdef USE_PTH_THREADS - pth_mutex_release (&mem_mutex); -#else pthread_mutex_unlock (&mem_mutex); -#endif return m->ptr; } } warnx (_("%s: %p not found"), __FUNCTION__, ptr); -#ifdef USE_PTH_THREADS - pth_mutex_release (&mem_mutex); -#else pthread_mutex_unlock (&mem_mutex); -#endif assert (0); return NULL; } @@ -303,20 +254,12 @@ xpanic (void) { struct memlist_s *m; -#ifdef USE_PTH_THREADS - pth_mutex_acquire (&mem_mutex, 0, NULL); -#else pthread_mutex_lock (&mem_mutex); -#endif for (m = memlist; m; m = memlist) xfree (m->ptr); -#ifdef USE_PTH_THREADS - pth_mutex_release (&mem_mutex); -#else pthread_mutex_unlock (&mem_mutex); -#endif } #ifdef DEBUG @@ -326,11 +269,7 @@ xdump (void) struct memlist_s *m; size_t total = 0; -#ifdef USE_PTH_THREADS - pth_mutex_acquire (&mem_mutex, 0, NULL); -#else pthread_mutex_lock (&mem_mutex); -#endif for (m = memlist; m; m = m->next) { @@ -341,10 +280,6 @@ xdump (void) fprintf (stderr, "Total unfreed: %i bytes, allocations: %i, deallocations: %i\n", total, allocations, deallocations); -#ifdef USE_PTH_THREADS - pth_mutex_release (&mem_mutex); -#else pthread_mutex_unlock (&mem_mutex); -#endif } #endif -- 2.11.4.GIT