X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Flzms-compress.c;h=2c9356d9b1a538006a7fc9dcae90404bc2c271a2;hb=ee4fcdd5c4924803ae67a09fecac7d6b4b8ead6e;hp=64a674214b0766b17a6758650ed6558f38c4e2f6;hpb=2fdc3bd720f5bc49680dc2284ea42a537d1acc07;p=wimlib diff --git a/src/lzms-compress.c b/src/lzms-compress.c index 64a67421..2c9356d9 100644 --- a/src/lzms-compress.c +++ b/src/lzms-compress.c @@ -124,7 +124,7 @@ struct lzms_range_encoder { * lzms_range_encoder_raw. */ struct lzms_range_encoder_raw *rc; - /* Bits recently encoded by this range encoder. This are used as in + /* Bits recently encoded by this range encoder. This is used as an * index into @prob_entries. */ u32 state; @@ -163,7 +163,7 @@ struct lzms_huffman_encoder { u8 lens[LZMS_MAX_NUM_SYMS]; /* The codeword of each symbol in the Huffman code. */ - u16 codewords[LZMS_MAX_NUM_SYMS]; + u32 codewords[LZMS_MAX_NUM_SYMS]; }; /* State of the LZMS compressor. */ @@ -666,17 +666,9 @@ lzms_do_init_rc_costs(void) static void lzms_init_rc_costs(void) { - static bool done = false; - static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; - - if (unlikely(!done)) { - pthread_mutex_lock(&mutex); - if (!done) { - lzms_do_init_rc_costs(); - done = true; - } - pthread_mutex_unlock(&mutex); - } + static pthread_once_t once = PTHREAD_ONCE_INIT; + + pthread_once(&once, lzms_do_init_rc_costs); } /*