* 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)
{
static uLong
crc32 (uLong crc, const char *buf, size_t len)
{
+ crc_init ();
GNUNET_assert (crc_table[255] != 0);
crc ^= 0xffffffff;
while (len--)
* @param len the length of the buffer
* @return the resulting CRC32 checksum
*/
-int
-GNUNET_CRYPTO_crc32_n (const void *buf, unsigned int len)
+int32_t
+GNUNET_CRYPTO_crc32_n (const void *buf, size_t len)
{
uLong crc;
crc = crc32 (0L, Z_NULL, 0);
return crc;
}
-/* end of crc32.c */
+/* end of crypto_crc.c */