X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Flzms-common.c;h=c657ef4aabccd60f58df5c5061b8c2587e8b28d8;hb=81c83fa2dbb44e788f234ddd5427c00e33c12d52;hp=a34fb245265bc5dab3013535ec16198aed593cbf;hpb=f7a403360d4d3adfb54492e25a28d9de0c627fa1;p=wimlib diff --git a/src/lzms-common.c b/src/lzms-common.c index a34fb245..c657ef4a 100644 --- a/src/lzms-common.c +++ b/src/lzms-common.c @@ -165,17 +165,9 @@ lzms_compute_slots(void) void lzms_init_slots(void) { - static bool done = false; - static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; - - if (unlikely(!done)) { - pthread_mutex_lock(&mutex); - if (!done) { - lzms_compute_slots(); - done = true; - } - pthread_mutex_unlock(&mutex); - } + static pthread_once_t once = PTHREAD_ONCE_INIT; + + pthread_once(&once, lzms_compute_slots); } static s32