projects
/
oweals
/
gnunet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed compile warnings under windows
[oweals/gnunet.git]
/
src
/
util
/
crypto_crc.c
diff --git
a/src/util/crypto_crc.c
b/src/util/crypto_crc.c
index 35d1e257689dc6b698bdc32a32d0a9c505aa3704..8f5cfc800e44a3da7bf0e432ba62fe5782070487 100644
(file)
--- 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.
*/
* 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;
unsigned int i, j;
uLong h = 1;
+
+ if (once)
+ return;
+ once = 1;
crc_table[0] = 0;
for (i = 128; i; i >>= 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)
{
static uLong
crc32 (uLong crc, const char *buf, size_t len)
{
+ crc_init ();
GNUNET_assert (crc_table[255] != 0);
crc ^= 0xffffffff;
while (len--)
GNUNET_assert (crc_table[255] != 0);
crc ^= 0xffffffff;
while (len--)
@@
-94,8
+101,8
@@
crc32 (uLong crc, const char *buf, size_t len)
* @param len the length of the buffer
* @return the resulting CRC32 checksum
*/
* @param len the length of the buffer
* @return the resulting CRC32 checksum
*/
-int
-GNUNET_CRYPTO_crc32_n (const void *buf,
unsigned in
t len)
+int
32_t
+GNUNET_CRYPTO_crc32_n (const void *buf,
size_
t len)
{
uLong crc;
crc = crc32 (0L, Z_NULL, 0);
{
uLong crc;
crc = crc32 (0L, Z_NULL, 0);
@@
-103,4
+110,4
@@
GNUNET_CRYPTO_crc32_n (const void *buf, unsigned int len)
return crc;
}
return crc;
}
-/* end of cr
c32
.c */
+/* end of cr
ypto_crc
.c */