Undo revision 23130 which was a merge with 2.5, a messy one because I did something...
[blender.git] / source / blender / blenlib / intern / threads.c
index ed3e07b..2812f17 100644 (file)
@@ -142,10 +142,10 @@ void BLI_init_threads(ListBase *threadbase, void *(*do_thread)(void *), int tot)
                        tslot->do_thread= do_thread;
                        tslot->avail= 1;
                }
-               
-               MEM_set_lock_callback(BLI_lock_malloc_thread, BLI_unlock_malloc_thread);
-               thread_levels++;
        }
+
+       MEM_set_lock_callback(BLI_lock_malloc_thread, BLI_unlock_malloc_thread);
+       thread_levels++;
 }
 
 /* amount of available threads */
@@ -235,21 +235,18 @@ void BLI_end_threads(ListBase *threadbase)
 {
        ThreadSlot *tslot;
        
-       /* only needed if there's actually some stuff to end
-        * this way we don't end up decrementing thread_levels on an empty threadbase 
-        * */
-       if (threadbase && threadbase->first != NULL) {
+       if (threadbase) {
                for(tslot= threadbase->first; tslot; tslot= tslot->next) {
                        if(tslot->avail==0) {
                                pthread_join(tslot->pthread, NULL);
                        }
                }
                BLI_freelistN(threadbase);
-
-               thread_levels--;
-               if(thread_levels==0)
-                       MEM_set_lock_callback(NULL, NULL);
        }
+       
+       thread_levels--;
+       if(thread_levels==0)
+               MEM_set_lock_callback(NULL, NULL);
 }
 
 void BLI_lock_thread(int type)