X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=utils%2Fthread_util.c;h=5ad5d47cad8efde111b5f2ba15564023fa11ded8;hb=aa75c7476aeaa84cf3abc192b376a8b03c325213;hp=bccb74626d3ccbe4caee8a4e80f2b7e22fc02217;hpb=d1ae2829ff0fd2a96c16a0c8c5420efaa47d7b30;p=xscreensaver diff --git a/utils/thread_util.c b/utils/thread_util.c index bccb7462..5ad5d47c 100644 --- a/utils/thread_util.c +++ b/utils/thread_util.c @@ -13,11 +13,6 @@ software for any purpose. It is provided "as is" without express or implied warranty. */ -#include "thread_util.h" - -#include "aligned_malloc.h" -#include "resources.h" - #if HAVE_CONFIG_H # include "config.h" #endif @@ -42,6 +37,11 @@ implied warranty. # include #endif +#include "thread_util.h" + +#include "aligned_malloc.h" +#include "resources.h" + #define IS_POWER_OF_2(x) ((x) > 0 && !((x) & ((x) - 1))) /* @@ -694,18 +694,16 @@ static void _unlock_and_destroy(struct threadpool *self) PTHREAD_VERIFY(pthread_mutex_unlock(&self->mutex)); - if(!threads) - return; - + if(threads) { unsigned i, count = _threadpool_count_parallel(self); for(i = 0; i != count; ++i) PTHREAD_VERIFY(pthread_join(threads[i], NULL)); - } - free(threads); - PTHREAD_VERIFY(pthread_cond_destroy(&self->cond)); - PTHREAD_VERIFY(pthread_mutex_destroy(&self->mutex)); + free(threads); + PTHREAD_VERIFY(pthread_cond_destroy(&self->cond)); + PTHREAD_VERIFY(pthread_mutex_destroy(&self->mutex)); + } _serial_destroy(self); }