From http://www.jwz.org/xscreensaver/xscreensaver-5.35.tar.gz
[xscreensaver] / utils / thread_util.c
index 76032c48f14585092e7d523d9d74c078f618e14c..5ad5d47cad8efde111b5f2ba15564023fa11ded8 100644 (file)
@@ -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
@@ -39,9 +34,14 @@ implied warranty.
 
 #if defined __MACH__ && defined __APPLE__ /* OS X, iOS */
 #      include <sys/sysctl.h>
-#      include <stdint.h>
+#      include <inttypes.h>
 #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);
 }