[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r8305 - in GNUnet/src/util: containers crypto
From: |
gnunet |
Subject: |
[GNUnet-SVN] r8305 - in GNUnet/src/util: containers crypto |
Date: |
Sun, 1 Mar 2009 19:25:06 -0700 |
Author: grothoff
Date: 2009-03-01 19:25:05 -0700 (Sun, 01 Mar 2009)
New Revision: 8305
Modified:
GNUnet/src/util/containers/bloomfilter.c
GNUnet/src/util/crypto/hashing.c
Log:
fix
Modified: GNUnet/src/util/containers/bloomfilter.c
===================================================================
--- GNUnet/src/util/containers/bloomfilter.c 2009-03-02 01:40:01 UTC (rev
8304)
+++ GNUnet/src/util/containers/bloomfilter.c 2009-03-02 02:25:05 UTC (rev
8305)
@@ -520,8 +520,11 @@
ui = 1;
while (ui < size)
ui *= 2;
- size = ui; /* make sure it's a power of 2 */
-
+ if (size != ui)
+ {
+ GNUNET_GE_BREAK (NULL, 0);
+ return NULL;
+ }
bf = GNUNET_malloc (sizeof (Bloomfilter));
bf->ectx = ectx;
bf->fd = -1;
@@ -530,7 +533,10 @@
bf->bitArray = GNUNET_malloc_large (size);
bf->bitArraySize = size;
bf->addressesPerElement = k;
- memset (bf->bitArray, 0, bf->bitArraySize);
+ if (data != NULL)
+ memcpy(bf->bitArray, data, size);
+ else
+ memset (bf->bitArray, 0, bf->bitArraySize);
return bf;
}
@@ -679,6 +685,8 @@
{
if (NULL == bf)
return;
+ if (bf->fd == -1)
+ return;
GNUNET_mutex_lock (bf->lock);
iterateBits (bf, &decrementBitCallback, NULL, e);
GNUNET_mutex_unlock (bf->lock);
Modified: GNUnet/src/util/crypto/hashing.c
===================================================================
--- GNUnet/src/util/crypto/hashing.c 2009-03-02 01:40:01 UTC (rev 8304)
+++ GNUnet/src/util/crypto/hashing.c 2009-03-02 02:25:05 UTC (rev 8305)
@@ -567,8 +567,9 @@
GNUNET_hash_distance_u32 (const GNUNET_HashCode * a,
const GNUNET_HashCode * b)
{
- unsigned int x = (a->bits[1] - b->bits[1]) >> 16;
- return ((x * x) >> 16);
+ unsigned int x1 = (a->bits[1] - b->bits[1]) >> 16;
+ unsigned int x2 = (b->bits[1] - a->bits[1]) >> 16;
+ return x1*x2;
}
void
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r8305 - in GNUnet/src/util: containers crypto,
gnunet <=