GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
}
static int
-add_iterator (void *cls,
- GNUNET_HashCode * next)
+add_iterator (void *cls, GNUNET_HashCode * next)
{
int *ret = cls;
GNUNET_HashCode pos;
bf = GNUNET_CONTAINER_bloomfilter_load (TESTFILE, SIZE, K);
for (i = 0; i < 200; i++)
- {
- nextHC (&tmp);
- GNUNET_CONTAINER_bloomfilter_add (bf, &tmp);
- }
+ {
+ nextHC (&tmp);
+ GNUNET_CONTAINER_bloomfilter_add (bf, &tmp);
+ }
SRANDOM (1);
ok1 = 0;
for (i = 0; i < 200; i++)
- {
- nextHC (&tmp);
- if (GNUNET_CONTAINER_bloomfilter_test (bf, &tmp) == GNUNET_YES)
- ok1++;
- }
+ {
+ nextHC (&tmp);
+ if (GNUNET_CONTAINER_bloomfilter_test (bf, &tmp) == GNUNET_YES)
+ ok1++;
+ }
if (ok1 != 200)
- {
- printf ("Got %d elements out of"
- "200 expected after insertion.\n", ok1);
- GNUNET_CONTAINER_bloomfilter_free (bf);
- return -1;
- }
+ {
+ printf ("Got %d elements out of" "200 expected after insertion.\n", ok1);
+ GNUNET_CONTAINER_bloomfilter_free (bf);
+ return -1;
+ }
if (GNUNET_OK != GNUNET_CONTAINER_bloomfilter_get_raw_data (bf, buf, SIZE))
- {
- GNUNET_CONTAINER_bloomfilter_free (bf);
- return -1;
- }
+ {
+ GNUNET_CONTAINER_bloomfilter_free (bf);
+ return -1;
+ }
GNUNET_CONTAINER_bloomfilter_free (bf);
ok1 = 0;
ok2 = 0;
for (i = 0; i < 200; i++)
- {
- nextHC (&tmp);
- if (GNUNET_CONTAINER_bloomfilter_test (bf, &tmp) == GNUNET_YES)
- ok1++;
- if (GNUNET_CONTAINER_bloomfilter_test (bfi, &tmp) == GNUNET_YES)
- ok2++;
- }
+ {
+ nextHC (&tmp);
+ if (GNUNET_CONTAINER_bloomfilter_test (bf, &tmp) == GNUNET_YES)
+ ok1++;
+ if (GNUNET_CONTAINER_bloomfilter_test (bfi, &tmp) == GNUNET_YES)
+ ok2++;
+ }
if (ok1 != 200)
- {
- printf ("Got %d elements out of 200 "
- "expected after reloading.\n", ok1);
- GNUNET_CONTAINER_bloomfilter_free (bf);
- GNUNET_CONTAINER_bloomfilter_free (bfi);
- return -1;
- }
+ {
+ printf ("Got %d elements out of 200 " "expected after reloading.\n", ok1);
+ GNUNET_CONTAINER_bloomfilter_free (bf);
+ GNUNET_CONTAINER_bloomfilter_free (bfi);
+ return -1;
+ }
if (ok2 != 200)
- {
- printf ("Got %d elements out of 200 "
- "expected after initialization.\n", ok2);
- GNUNET_CONTAINER_bloomfilter_free (bf);
- GNUNET_CONTAINER_bloomfilter_free (bfi);
- return -1;
- }
+ {
+ printf ("Got %d elements out of 200 " "expected after initialization.\n",
+ ok2);
+ GNUNET_CONTAINER_bloomfilter_free (bf);
+ GNUNET_CONTAINER_bloomfilter_free (bfi);
+ return -1;
+ }
SRANDOM (1);
for (i = 0; i < 100; i++)
- {
- nextHC (&tmp);
- GNUNET_CONTAINER_bloomfilter_remove (bf, &tmp);
- GNUNET_CONTAINER_bloomfilter_remove (bfi, &tmp);
- }
+ {
+ nextHC (&tmp);
+ GNUNET_CONTAINER_bloomfilter_remove (bf, &tmp);
+ GNUNET_CONTAINER_bloomfilter_remove (bfi, &tmp);
+ }
SRANDOM (1);
ok1 = 0;
ok2 = 0;
for (i = 0; i < 200; i++)
- {
- nextHC (&tmp);
- if (GNUNET_CONTAINER_bloomfilter_test (bf, &tmp) == GNUNET_YES)
- ok1++;
- if (GNUNET_CONTAINER_bloomfilter_test (bfi, &tmp) == GNUNET_YES)
- ok2++;
- }
+ {
+ nextHC (&tmp);
+ if (GNUNET_CONTAINER_bloomfilter_test (bf, &tmp) == GNUNET_YES)
+ ok1++;
+ if (GNUNET_CONTAINER_bloomfilter_test (bfi, &tmp) == GNUNET_YES)
+ ok2++;
+ }
if (ok1 != 100)
- {
- printf ("Expected 100 elements in loaded filter"
- " after adding 200 and deleting 100, got %d\n", ok1);
- GNUNET_CONTAINER_bloomfilter_free (bf);
- GNUNET_CONTAINER_bloomfilter_free (bfi);
- return -1;
- }
+ {
+ printf ("Expected 100 elements in loaded filter"
+ " after adding 200 and deleting 100, got %d\n", ok1);
+ GNUNET_CONTAINER_bloomfilter_free (bf);
+ GNUNET_CONTAINER_bloomfilter_free (bfi);
+ return -1;
+ }
if (ok2 != 200)
- {
- printf ("Expected 200 elements in initialized filter"
- " after adding 200 and deleting 100 "
- "(which should do nothing for a filter not backed by a file), got %d\n",
- ok2);
- GNUNET_CONTAINER_bloomfilter_free (bf);
- GNUNET_CONTAINER_bloomfilter_free (bfi);
- return -1;
- }
+ {
+ printf ("Expected 200 elements in initialized filter"
+ " after adding 200 and deleting 100 "
+ "(which should do nothing for a filter not backed by a file), got %d\n",
+ ok2);
+ GNUNET_CONTAINER_bloomfilter_free (bf);
+ GNUNET_CONTAINER_bloomfilter_free (bfi);
+ return -1;
+ }
SRANDOM (3);
GNUNET_CONTAINER_bloomfilter_clear (bf);
falseok = 0;
for (i = 0; i < 1000; i++)
- {
- nextHC (&tmp);
- if (GNUNET_CONTAINER_bloomfilter_test (bf, &tmp) == GNUNET_YES)
- falseok++;
- }
+ {
+ nextHC (&tmp);
+ if (GNUNET_CONTAINER_bloomfilter_test (bf, &tmp) == GNUNET_YES)
+ falseok++;
+ }
if (falseok > 0)
- {
- GNUNET_CONTAINER_bloomfilter_free (bf);
- GNUNET_CONTAINER_bloomfilter_free (bfi);
- return -1;
- }
+ {
+ GNUNET_CONTAINER_bloomfilter_free (bf);
+ GNUNET_CONTAINER_bloomfilter_free (bfi);
+ return -1;
+ }
if (GNUNET_OK != GNUNET_CONTAINER_bloomfilter_or (bf, buf, SIZE))
- {
- GNUNET_CONTAINER_bloomfilter_free (bf);
- GNUNET_CONTAINER_bloomfilter_free (bfi);
- return -1;
- }
+ {
+ GNUNET_CONTAINER_bloomfilter_free (bf);
+ GNUNET_CONTAINER_bloomfilter_free (bfi);
+ return -1;
+ }
SRANDOM (2);
i = 20;
ok1 = 0;
ok2 = 0;
for (i = 0; i < 20; i++)
- {
- nextHC (&tmp);
- if (GNUNET_CONTAINER_bloomfilter_test (bf, &tmp) == GNUNET_YES)
- ok1++;
- if (GNUNET_CONTAINER_bloomfilter_test (bfi, &tmp) == GNUNET_YES)
- ok2++;
- }
+ {
+ nextHC (&tmp);
+ if (GNUNET_CONTAINER_bloomfilter_test (bf, &tmp) == GNUNET_YES)
+ ok1++;
+ if (GNUNET_CONTAINER_bloomfilter_test (bfi, &tmp) == GNUNET_YES)
+ ok2++;
+ }
if (ok1 != 20)
- {
- printf ("Expected 20 elements in resized file-backed filter"
- " after adding 20, got %d\n", ok1);
- GNUNET_CONTAINER_bloomfilter_free (bf);
- GNUNET_CONTAINER_bloomfilter_free (bfi);
- return -1;
- }
+ {
+ printf ("Expected 20 elements in resized file-backed filter"
+ " after adding 20, got %d\n", ok1);
+ GNUNET_CONTAINER_bloomfilter_free (bf);
+ GNUNET_CONTAINER_bloomfilter_free (bfi);
+ return -1;
+ }
if (ok2 != 20)
- {
- printf ("Expected 20 elements in resized filter"
- " after adding 20, got %d\n", ok2);
- GNUNET_CONTAINER_bloomfilter_free (bf);
- GNUNET_CONTAINER_bloomfilter_free (bfi);
- return -1;
- }
+ {
+ printf ("Expected 20 elements in resized filter"
+ " after adding 20, got %d\n", ok2);
+ GNUNET_CONTAINER_bloomfilter_free (bf);
+ GNUNET_CONTAINER_bloomfilter_free (bfi);
+ return -1;
+ }
GNUNET_CONTAINER_bloomfilter_free (bf);