diff options
author | Christian Grothoff <christian@grothoff.org> | 2009-08-29 19:46:39 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2009-08-29 19:46:39 +0000 |
commit | ab3a3be75688c71b23570406816dbd12c67529ec (patch) | |
tree | 83174f4313261c9f613fb947c5576e24c36f3f10 /src/util/container_bloomfilter.c | |
parent | db5fce6cd527aa49fb5762d730564a918131a30f (diff) | |
download | gnunet-ab3a3be75688c71b23570406816dbd12c67529ec.tar.gz gnunet-ab3a3be75688c71b23570406816dbd12c67529ec.zip |
more fixes
Diffstat (limited to 'src/util/container_bloomfilter.c')
-rw-r--r-- | src/util/container_bloomfilter.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/src/util/container_bloomfilter.c b/src/util/container_bloomfilter.c index 9efc2647c..5cc947bd6 100644 --- a/src/util/container_bloomfilter.c +++ b/src/util/container_bloomfilter.c | |||
@@ -277,12 +277,13 @@ makeEmptyFile (const struct GNUNET_DISK_FileHandle *fh, unsigned int size) | |||
277 | * bloomfilter iterator on each bit that is to be | 277 | * bloomfilter iterator on each bit that is to be |
278 | * set or tested for the key. | 278 | * set or tested for the key. |
279 | * | 279 | * |
280 | * @param cls closure | ||
280 | * @param bf the filter to manipulate | 281 | * @param bf the filter to manipulate |
281 | * @param bit the current bit | 282 | * @param bit the current bit |
282 | * @param additional context specific argument | ||
283 | */ | 283 | */ |
284 | typedef void (*BitIterator) (struct GNUNET_CONTAINER_BloomFilter * bf, | 284 | typedef void (*BitIterator) (void *cls, |
285 | unsigned int bit, void *arg); | 285 | struct GNUNET_CONTAINER_BloomFilter * bf, |
286 | unsigned int bit); | ||
286 | 287 | ||
287 | /** | 288 | /** |
288 | * Call an iterator for each bit that the bloomfilter | 289 | * Call an iterator for each bit that the bloomfilter |
@@ -309,9 +310,10 @@ iterateBits (struct GNUNET_CONTAINER_BloomFilter *bf, | |||
309 | { | 310 | { |
310 | while (slot < (sizeof (GNUNET_HashCode) / sizeof (unsigned int))) | 311 | while (slot < (sizeof (GNUNET_HashCode) / sizeof (unsigned int))) |
311 | { | 312 | { |
312 | callback (bf, | 313 | callback (arg, |
314 | bf, | ||
313 | (((unsigned int *) &tmp[round & 1])[slot]) & | 315 | (((unsigned int *) &tmp[round & 1])[slot]) & |
314 | ((bf->bitArraySize * 8) - 1), arg); | 316 | ((bf->bitArraySize * 8) - 1)); |
315 | slot++; | 317 | slot++; |
316 | bitCount--; | 318 | bitCount--; |
317 | if (bitCount == 0) | 319 | if (bitCount == 0) |
@@ -330,13 +332,14 @@ iterateBits (struct GNUNET_CONTAINER_BloomFilter *bf, | |||
330 | /** | 332 | /** |
331 | * Callback: increment bit | 333 | * Callback: increment bit |
332 | * | 334 | * |
335 | * @param cls not used | ||
333 | * @param bf the filter to manipulate | 336 | * @param bf the filter to manipulate |
334 | * @param bit the bit to increment | 337 | * @param bit the bit to increment |
335 | * @param arg not used | ||
336 | */ | 338 | */ |
337 | static void | 339 | static void |
338 | incrementBitCallback (struct GNUNET_CONTAINER_BloomFilter *bf, | 340 | incrementBitCallback (void *cls, |
339 | unsigned int bit, void *arg) | 341 | struct GNUNET_CONTAINER_BloomFilter *bf, |
342 | unsigned int bit) | ||
340 | { | 343 | { |
341 | incrementBit (bf->bitArray, bit, bf->fh); | 344 | incrementBit (bf->bitArray, bit, bf->fh); |
342 | } | 345 | } |
@@ -344,13 +347,14 @@ incrementBitCallback (struct GNUNET_CONTAINER_BloomFilter *bf, | |||
344 | /** | 347 | /** |
345 | * Callback: decrement bit | 348 | * Callback: decrement bit |
346 | * | 349 | * |
350 | * @param cls not used | ||
347 | * @param bf the filter to manipulate | 351 | * @param bf the filter to manipulate |
348 | * @param bit the bit to decrement | 352 | * @param bit the bit to decrement |
349 | * @param arg not used | ||
350 | */ | 353 | */ |
351 | static void | 354 | static void |
352 | decrementBitCallback (struct GNUNET_CONTAINER_BloomFilter *bf, | 355 | decrementBitCallback (void *cls, |
353 | unsigned int bit, void *arg) | 356 | struct GNUNET_CONTAINER_BloomFilter *bf, |
357 | unsigned int bit) | ||
354 | { | 358 | { |
355 | decrementBit (bf->bitArray, bit, bf->fh); | 359 | decrementBit (bf->bitArray, bit, bf->fh); |
356 | } | 360 | } |
@@ -358,13 +362,13 @@ decrementBitCallback (struct GNUNET_CONTAINER_BloomFilter *bf, | |||
358 | /** | 362 | /** |
359 | * Callback: test if all bits are set | 363 | * Callback: test if all bits are set |
360 | * | 364 | * |
365 | * @param cls pointer set to GNUNET_NO if bit is not set | ||
361 | * @param bf the filter | 366 | * @param bf the filter |
362 | * @param bit the bit to test | 367 | * @param bit the bit to test |
363 | * @param arg pointer set to GNUNET_NO if bit is not set | ||
364 | */ | 368 | */ |
365 | static void | 369 | static void |
366 | testBitCallback (struct GNUNET_CONTAINER_BloomFilter *bf, unsigned int bit, | 370 | testBitCallback (void *cls, |
367 | void *cls) | 371 | struct GNUNET_CONTAINER_BloomFilter *bf, unsigned int bit) |
368 | { | 372 | { |
369 | int *arg = cls; | 373 | int *arg = cls; |
370 | if (GNUNET_NO == testBit (bf->bitArray, bit)) | 374 | if (GNUNET_NO == testBit (bf->bitArray, bit)) |
@@ -674,7 +678,7 @@ GNUNET_CONTAINER_bloomfilter_resize (struct GNUNET_CONTAINER_BloomFilter *bf, | |||
674 | memset (bf->bitArray, 0, bf->bitArraySize); | 678 | memset (bf->bitArray, 0, bf->bitArraySize); |
675 | if (bf->filename != NULL) | 679 | if (bf->filename != NULL) |
676 | makeEmptyFile (bf->fh, bf->bitArraySize * 4); | 680 | makeEmptyFile (bf->fh, bf->bitArraySize * 4); |
677 | while (GNUNET_YES == iterator (&hc, iterator_arg)) | 681 | while (GNUNET_YES == iterator (iterator_arg, &hc)) |
678 | GNUNET_CONTAINER_bloomfilter_add (bf, &hc); | 682 | GNUNET_CONTAINER_bloomfilter_add (bf, &hc); |
679 | } | 683 | } |
680 | 684 | ||