[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r25619 - gnunet/src/consensus
From: |
gnunet |
Subject: |
[GNUnet-SVN] r25619 - gnunet/src/consensus |
Date: |
Fri, 21 Dec 2012 13:21:41 +0100 |
Author: grothoff
Date: 2012-12-21 13:21:41 +0100 (Fri, 21 Dec 2012)
New Revision: 25619
Modified:
gnunet/src/consensus/ibf.c
Log:
-no alloca
Modified: gnunet/src/consensus/ibf.c
===================================================================
--- gnunet/src/consensus/ibf.c 2012-12-21 11:38:52 UTC (rev 25618)
+++ gnunet/src/consensus/ibf.c 2012-12-21 12:21:41 UTC (rev 25619)
@@ -113,49 +113,50 @@
struct GNUNET_HashCode bucket_indices;
struct GNUNET_HashCode key_copy;
struct GNUNET_HashCode key_hash;
- int *used_buckets;
unsigned int i;
GNUNET_assert ((1 == side) || (-1 == side));
GNUNET_assert (NULL != ibf);
- used_buckets = alloca (ibf->hash_num * sizeof (int));
+ {
+ int used_buckets[ibf->hash_num];
- /* copy the key, if key and an entry in the IBF alias */
- key_copy = *key;
+ /* copy the key, if key and an entry in the IBF alias */
+ key_copy = *key;
- bucket_indices = key_copy;
- GNUNET_CRYPTO_hash (key, sizeof (struct GNUNET_HashCode), &key_hash);
-
- for (i = 0; i < ibf->hash_num; i++)
- {
- unsigned int bucket;
- unsigned int j;
- int collided;
+ bucket_indices = key_copy;
+ GNUNET_CRYPTO_hash (key, sizeof (struct GNUNET_HashCode), &key_hash);
- if ((i % 16) == 0)
- GNUNET_CRYPTO_hash (&bucket_indices, sizeof (struct GNUNET_HashCode),
- &bucket_indices);
-
- bucket = bucket_indices.bits[i%16] % ibf->size;
- collided = GNUNET_NO;
- for (j = 0; j < i; j++)
- if (used_buckets[j] == bucket)
- collided = GNUNET_YES;
- if (GNUNET_YES == collided)
+ for (i = 0; i < ibf->hash_num; i++)
{
- used_buckets[i] = -1;
- continue;
+ unsigned int bucket;
+ unsigned int j;
+ int collided;
+
+ if ((i % 16) == 0)
+ GNUNET_CRYPTO_hash (&bucket_indices, sizeof (struct GNUNET_HashCode),
+ &bucket_indices);
+
+ bucket = bucket_indices.bits[i%16] % ibf->size;
+ collided = GNUNET_NO;
+ for (j = 0; j < i; j++)
+ if (used_buckets[j] == bucket)
+ collided = GNUNET_YES;
+ if (GNUNET_YES == collided)
+ {
+ used_buckets[i] = -1;
+ continue;
+ }
+ used_buckets[i] = bucket;
+
+ ibf->count[bucket] += side;
+
+ GNUNET_CRYPTO_hash_xor (&key_copy, &ibf->id_sum[bucket],
+ &ibf->id_sum[bucket]);
+ GNUNET_CRYPTO_hash_xor (&key_hash, &ibf->hash_sum[bucket],
+ &ibf->hash_sum[bucket]);
}
- used_buckets[i] = bucket;
-
- ibf->count[bucket] += side;
-
- GNUNET_CRYPTO_hash_xor (&key_copy, &ibf->id_sum[bucket],
- &ibf->id_sum[bucket]);
- GNUNET_CRYPTO_hash_xor (&key_hash, &ibf->hash_sum[bucket],
- &ibf->hash_sum[bucket]);
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r25619 - gnunet/src/consensus,
gnunet <=