X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Futil%2Fcrypto_crc.c;h=8f5cfc800e44a3da7bf0e432ba62fe5782070487;hb=8226d9807819dbbc4b05751f4cdd09603832367d;hp=a89b059c5cc029cb9f2ee46ef7603d15c1720582;hpb=c2017c2ba13736ee1fe4dc9d811d49bee1641ca3;p=oweals%2Fgnunet.git diff --git a/src/util/crypto_crc.c b/src/util/crypto_crc.c index a89b059c5..8f5cfc800 100644 --- a/src/util/crypto_crc.c +++ b/src/util/crypto_crc.c @@ -52,10 +52,16 @@ static uLong crc_table[256]; * with the ccorrect final value. Thus, it is safe to call * even on a table that someone else is using concurrently. */ -void __attribute__ ((constructor)) GNUNET_CRYPTO_crc_init () +static void +crc_init () { + static int once; unsigned int i, j; uLong h = 1; + + if (once) + return; + once = 1; crc_table[0] = 0; for (i = 128; i; i >>= 1) { @@ -79,6 +85,7 @@ void __attribute__ ((constructor)) GNUNET_CRYPTO_crc_init () static uLong crc32 (uLong crc, const char *buf, size_t len) { + crc_init (); GNUNET_assert (crc_table[255] != 0); crc ^= 0xffffffff; while (len--)