GNUnet  0.17.6
container_bloomfilter.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2001, 2002, 2003, 2004, 2006, 2008, 2011, 2012, 2018 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
42 #include "platform.h"
43 #include "gnunet_util_lib.h"
44 
45 #define LOG(kind, ...) \
46  GNUNET_log_from (kind, "util-container-bloomfilter", __VA_ARGS__)
47 
48 #define LOG_STRERROR(kind, syscall) \
49  GNUNET_log_from_strerror (kind, "util-container-bloomfilter", syscall)
50 
51 #define LOG_STRERROR_FILE(kind, syscall, filename) \
52  GNUNET_log_from_strerror_file (kind, \
53  "util-container-bloomfilter", \
54  syscall, \
55  filename)
56 
58 {
62  char *bitArray;
63 
67  char *filename;
68 
73 
77  unsigned int addressesPerElement;
78 
82  size_t bitArraySize;
83 };
84 
85 
86 size_t
88  const struct GNUNET_CONTAINER_BloomFilter *bf)
89 {
90  if (bf == NULL)
91  return 0;
92  return bf->addressesPerElement;
93 }
94 
95 
96 size_t
98  const struct GNUNET_CONTAINER_BloomFilter *bf)
99 {
100  if (bf == NULL)
101  return 0;
102  return bf->bitArraySize;
103 }
104 
105 
108  const struct GNUNET_CONTAINER_BloomFilter *bf)
109 {
111  bf->bitArraySize,
112  bf->addressesPerElement);
113 }
114 
115 
123 static void
125  unsigned int bitIdx)
126 {
127  size_t arraySlot;
128  unsigned int targetBit;
129 
130  arraySlot = bitIdx / 8;
131  targetBit = (1L << (bitIdx % 8));
132  bitArray[arraySlot] |= targetBit;
133 }
134 
135 
143 static void
144 clearBit (char *bitArray, unsigned int bitIdx)
145 {
146  size_t slot;
147  unsigned int targetBit;
148 
149  slot = bitIdx / 8;
150  targetBit = (1L << (bitIdx % 8));
151  bitArray[slot] = bitArray[slot] & (~targetBit);
152 }
153 
154 
162 static bool
164  unsigned int bitIdx)
165 {
166  size_t slot;
167  unsigned int targetBit;
168 
169  slot = bitIdx / 8;
170  targetBit = (1L << (bitIdx % 8));
171  if (bitArray[slot] & targetBit)
172  return true;
173  return false;
174 }
175 
176 
186 static void
188  unsigned int bitIdx,
189  const struct GNUNET_DISK_FileHandle *fh)
190 {
191  off_t fileSlot;
192  unsigned char value;
193  unsigned int high;
194  unsigned int low;
195  unsigned int targetLoc;
196 
197  setBit (bitArray,
198  bitIdx);
200  return;
201  /* Update the counter file on disk */
202  fileSlot = bitIdx / 2;
203  targetLoc = bitIdx % 2;
204 
205  GNUNET_assert (fileSlot ==
207  if (1 != GNUNET_DISK_file_read (fh, &value, 1))
208  value = 0;
209  low = value & 0xF;
210  high = (value & (~0xF)) >> 4;
211 
212  if (targetLoc == 0)
213  {
214  if (low < 0xF)
215  low++;
216  }
217  else
218  {
219  if (high < 0xF)
220  high++;
221  }
222  value = ((high << 4) | low);
223  GNUNET_assert (fileSlot ==
226 }
227 
228 
237 static void
239  unsigned int bitIdx,
240  const struct GNUNET_DISK_FileHandle *fh)
241 {
242  off_t fileslot;
243  unsigned char value;
244  unsigned int high;
245  unsigned int low;
246  unsigned int targetLoc;
247 
249  return; /* cannot decrement! */
250  /* Each char slot in the counter file holds two 4 bit counters */
251  fileslot = bitIdx / 2;
252  targetLoc = bitIdx % 2;
253  if (GNUNET_SYSERR ==
255  {
257  return;
258  }
259  if (1 != GNUNET_DISK_file_read (fh, &value, 1))
260  value = 0;
261  low = value & 0xF;
262  high = (value & 0xF0) >> 4;
263 
264  /* decrement, but once we have reached the max, never go back! */
265  if (targetLoc == 0)
266  {
267  if ((low > 0) && (low < 0xF))
268  low--;
269  if (low == 0)
270  {
271  clearBit (bitArray, bitIdx);
272  }
273  }
274  else
275  {
276  if ((high > 0) && (high < 0xF))
277  high--;
278  if (high == 0)
279  {
280  clearBit (bitArray, bitIdx);
281  }
282  }
283  value = ((high << 4) | low);
284  if (GNUNET_SYSERR ==
286  {
288  return;
289  }
291 }
292 
293 
294 #define BUFFSIZE 65536
295 
303 static enum GNUNET_GenericReturnValue
305  size_t size)
306 {
307  char buffer[BUFFSIZE];
308  size_t bytesleft = size;
309  int res = 0;
310 
312  return GNUNET_SYSERR;
313  memset (buffer, 0, sizeof(buffer));
315  while (bytesleft > 0)
316  {
317  if (bytesleft > sizeof(buffer))
318  {
319  res = GNUNET_DISK_file_write (fh, buffer, sizeof(buffer));
320  if (res >= 0)
321  bytesleft -= res;
322  }
323  else
324  {
325  res = GNUNET_DISK_file_write (fh, buffer, bytesleft);
326  if (res >= 0)
327  bytesleft -= res;
328  }
329  if (GNUNET_SYSERR == res)
330  return GNUNET_SYSERR;
331  }
332  return GNUNET_OK;
333 }
334 
335 
336 /* ************** GNUNET_CONTAINER_BloomFilter iterator ********* */
337 
348 typedef enum GNUNET_GenericReturnValue
349 (*BitIterator)(void *cls,
350  const struct GNUNET_CONTAINER_BloomFilter *bf,
351  unsigned int bit);
352 
353 
363 static void
365  BitIterator callback,
366  void *arg,
367  const struct GNUNET_HashCode *key)
368 {
369  struct GNUNET_HashCode tmp = *key;
370  int bitCount;
371  unsigned int slot = 0;
372 
373  bitCount = bf->addressesPerElement;
374  GNUNET_assert (bf->bitArraySize > 0);
375  GNUNET_assert (bf->bitArraySize * 8LL > bf->bitArraySize);
376  while (bitCount > 0)
377  {
378  while ( (0 != bitCount) &&
379  (slot < (sizeof(struct GNUNET_HashCode) / sizeof(uint32_t))) )
380  {
381  if (GNUNET_YES !=
382  callback (arg,
383  bf,
384  ntohl ((((uint32_t *) &tmp)[slot]))
385  % ((bf->bitArraySize * 8LL))))
386  return;
387  slot++;
388  bitCount--;
389  }
390  if (0 == bitCount)
391  break;
392  GNUNET_CRYPTO_hash (&tmp,
393  sizeof(tmp),
394  &tmp);
395  slot = 0;
396  }
397 }
398 
399 
408 static enum GNUNET_GenericReturnValue
409 incrementBitCallback (void *cls,
410  const struct GNUNET_CONTAINER_BloomFilter *bf,
411  unsigned int bit)
412 {
413  struct GNUNET_CONTAINER_BloomFilter *b = cls;
414 
416  bit,
417  bf->fh);
418  return GNUNET_YES;
419 }
420 
421 
430 static enum GNUNET_GenericReturnValue
431 decrementBitCallback (void *cls,
432  const struct GNUNET_CONTAINER_BloomFilter *bf,
433  unsigned int bit)
434 {
435  struct GNUNET_CONTAINER_BloomFilter *b = cls;
436 
438  bit,
439  bf->fh);
440  return GNUNET_YES;
441 }
442 
443 
452 static enum GNUNET_GenericReturnValue
453 testBitCallback (void *cls,
454  const struct GNUNET_CONTAINER_BloomFilter *bf,
455  unsigned int bit)
456 {
457  bool *arg = cls;
458 
459  if (! testBit (bf->bitArray, bit))
460  {
461  *arg = false;
462  return GNUNET_NO;
463  }
464  return GNUNET_YES;
465 }
466 
467 
468 /* *********************** INTERFACE **************** */
469 
472  size_t size,
473  unsigned int k)
474 {
475  struct GNUNET_CONTAINER_BloomFilter *bf;
476  char *rbuff;
477  off_t pos;
478  int i;
479  size_t ui;
480  off_t fsize;
481  int must_read;
482 
483  GNUNET_assert (NULL != filename);
484  if ((k == 0) || (size == 0))
485  return NULL;
486  if (size < BUFFSIZE)
487  size = BUFFSIZE;
488  ui = 1;
489  while ((ui < size) && (ui * 2 > ui))
490  ui *= 2;
491  size = ui; /* make sure it's a power of 2 */
492 
494  /* Try to open a bloomfilter file */
500  if (NULL != bf->fh)
501  {
502  /* file existed, try to read it! */
503  must_read = GNUNET_YES;
504  if (GNUNET_OK !=
506  &fsize))
507  {
509  GNUNET_free (bf);
510  return NULL;
511  }
512  if (0 == fsize)
513  {
514  /* found existing empty file, just overwrite */
515  if (GNUNET_OK !=
516  make_empty_file (bf->fh,
517  size * 4LL))
518  {
520  "write");
522  GNUNET_free (bf);
523  return NULL;
524  }
525  }
526  else if (fsize != ((off_t) size) * 4LL)
527  {
528  GNUNET_log (
530  _ (
531  "Size of file on disk is incorrect for this Bloom filter (want %llu, have %llu)\n"),
532  (unsigned long long) (size * 4LL),
533  (unsigned long long) fsize);
535  GNUNET_free (bf);
536  return NULL;
537  }
538  }
539  else
540  {
541  /* file did not exist, don't read, just create */
542  must_read = GNUNET_NO;
548  if (NULL == bf->fh)
549  {
550  GNUNET_free (bf);
551  return NULL;
552  }
553  if (GNUNET_OK != make_empty_file (bf->fh, size * 4LL))
554  {
557  GNUNET_free (bf);
558  return NULL;
559  }
560  }
562  /* Alloc block */
564  if (NULL == bf->bitArray)
565  {
566  if (NULL != bf->fh)
568  GNUNET_free (bf->filename);
569  GNUNET_free (bf);
570  return NULL;
571  }
572  bf->bitArraySize = size;
573  bf->addressesPerElement = k;
574  if (GNUNET_YES != must_read)
575  return bf; /* already done! */
576  /* Read from the file what bits we can */
577  rbuff = GNUNET_malloc (BUFFSIZE);
578  pos = 0;
579  while (pos < ((off_t) size) * 8LL)
580  {
581  int res;
582 
583  res = GNUNET_DISK_file_read (bf->fh, rbuff, BUFFSIZE);
584  if (res == -1)
585  {
587  GNUNET_free (rbuff);
588  GNUNET_free (bf->filename);
590  GNUNET_free (bf);
591  return NULL;
592  }
593  if (res == 0)
594  break; /* is ok! we just did not use that many bits yet */
595  for (i = 0; i < res; i++)
596  {
597  if ((rbuff[i] & 0x0F) != 0)
598  setBit (bf->bitArray, pos + i * 2);
599  if ((rbuff[i] & 0xF0) != 0)
600  setBit (bf->bitArray, pos + i * 2 + 1);
601  }
602  if (res < BUFFSIZE)
603  break;
604  pos += BUFFSIZE * 2; /* 2 bits per byte in the buffer */
605  }
606  GNUNET_free (rbuff);
607  return bf;
608 }
609 
610 
613  size_t size,
614  unsigned int k)
615 {
616  struct GNUNET_CONTAINER_BloomFilter *bf;
617 
618  if ((0 == k) || (0 == size))
619  return NULL;
621  bf->filename = NULL;
622  bf->fh = NULL;
624  if (NULL == bf->bitArray)
625  {
626  GNUNET_free (bf);
627  return NULL;
628  }
629  bf->bitArraySize = size;
630  bf->addressesPerElement = k;
631  if (NULL != data)
633  return bf;
634 }
635 
636 
639  const struct GNUNET_CONTAINER_BloomFilter *bf,
640  char *data,
641  size_t size)
642 {
643  if (NULL == bf)
644  return GNUNET_SYSERR;
645  if (bf->bitArraySize != size)
646  return GNUNET_SYSERR;
648  return GNUNET_OK;
649 }
650 
651 
652 void
654 {
655  if (NULL == bf)
656  return;
657  if (bf->fh != NULL)
659  GNUNET_free (bf->filename);
660  GNUNET_free (bf->bitArray);
661  GNUNET_free (bf);
662 }
663 
664 
665 void
667 {
668  if (NULL == bf)
669  return;
670 
671  memset (bf->bitArray, 0, bf->bitArraySize);
672  if (bf->filename != NULL)
673  make_empty_file (bf->fh, bf->bitArraySize * 4LL);
674 }
675 
676 
677 bool
679  const struct GNUNET_CONTAINER_BloomFilter *bf,
680  const struct GNUNET_HashCode *e)
681 {
682  bool res;
683 
684  if (NULL == bf)
685  return true;
686  res = true;
687  iterateBits (bf,
689  &res,
690  e);
691  return res;
692 }
693 
694 
695 void
697  const struct GNUNET_HashCode *e)
698 {
699  if (NULL == bf)
700  return;
701  iterateBits (bf,
703  bf,
704  e);
705 }
706 
707 
710  const char *data,
711  size_t size)
712 {
713  unsigned int i;
714  unsigned int n;
715  unsigned long long *fc;
716  const unsigned long long *dc;
717 
718  if (NULL == bf)
719  return GNUNET_YES;
720  if (bf->bitArraySize != size)
721  return GNUNET_SYSERR;
722  fc = (unsigned long long *) bf->bitArray;
723  dc = (const unsigned long long *) data;
724  n = size / sizeof(unsigned long long);
725 
726  for (i = 0; i < n; i++)
727  fc[i] |= dc[i];
728  for (i = n * sizeof(unsigned long long); i < size; i++)
729  bf->bitArray[i] |= data[i];
730  return GNUNET_OK;
731 }
732 
733 
736  struct GNUNET_CONTAINER_BloomFilter *bf,
737  const struct GNUNET_CONTAINER_BloomFilter *to_or)
738 {
739  unsigned int i;
740  unsigned int n;
741  unsigned long long *fc;
742  const unsigned long long *dc;
743  size_t size;
744 
745  if (NULL == bf)
746  return GNUNET_OK;
747  if (bf->bitArraySize != to_or->bitArraySize)
748  {
749  GNUNET_break (0);
750  return GNUNET_SYSERR;
751  }
752  size = bf->bitArraySize;
753  fc = (unsigned long long *) bf->bitArray;
754  dc = (const unsigned long long *) to_or->bitArray;
755  n = size / sizeof(unsigned long long);
756 
757  for (i = 0; i < n; i++)
758  fc[i] |= dc[i];
759  for (i = n * sizeof(unsigned long long); i < size; i++)
760  bf->bitArray[i] |= to_or->bitArray[i];
761  return GNUNET_OK;
762 }
763 
764 
765 void
767  const struct GNUNET_HashCode *e)
768 {
769  if (NULL == bf)
770  return;
771  if (NULL == bf->filename)
772  return;
773  iterateBits (bf,
775  bf,
776  e);
777 }
778 
779 
780 void
783  void *iterator_cls,
784  size_t size,
785  unsigned int k)
786 {
787  struct GNUNET_HashCode hc;
788  unsigned int i;
789 
790  GNUNET_free (bf->bitArray);
791  i = 1;
792  while (i < size)
793  i *= 2;
794  size = i; /* make sure it's a power of 2 */
795  bf->addressesPerElement = k;
796  bf->bitArraySize = size;
797  bf->bitArray = GNUNET_malloc (size);
798  if (NULL != bf->filename)
799  make_empty_file (bf->fh, bf->bitArraySize * 4LL);
800  while (GNUNET_YES == iterator (iterator_cls, &hc))
802 }
803 
804 
805 /* end of container_bloomfilter.c */
#define BUFFSIZE
static enum GNUNET_GenericReturnValue make_empty_file(const struct GNUNET_DISK_FileHandle *fh, size_t size)
Creates a file filled with zeroes.
static enum GNUNET_GenericReturnValue testBitCallback(void *cls, const struct GNUNET_CONTAINER_BloomFilter *bf, unsigned int bit)
Callback: test if all bits are set.
static void incrementBit(char *bitArray, unsigned int bitIdx, const struct GNUNET_DISK_FileHandle *fh)
Sets a bit active in the bitArray and increments bit-specific usage counter on disk (but only if the ...
static void decrementBit(char *bitArray, unsigned int bitIdx, const struct GNUNET_DISK_FileHandle *fh)
Clears a bit from bitArray if the respective usage counter on the disk hits/is zero.
static enum GNUNET_GenericReturnValue incrementBitCallback(void *cls, const struct GNUNET_CONTAINER_BloomFilter *bf, unsigned int bit)
Callback: increment bit.
static void clearBit(char *bitArray, unsigned int bitIdx)
Clears a bit from bitArray.
#define LOG_STRERROR_FILE(kind, syscall, filename)
static void setBit(char *bitArray, unsigned int bitIdx)
Sets a bit active in the bitArray.
enum GNUNET_GenericReturnValue(* BitIterator)(void *cls, const struct GNUNET_CONTAINER_BloomFilter *bf, unsigned int bit)
Iterator (callback) method to be called by the bloomfilter iterator on each bit that is to be set or ...
static void iterateBits(const struct GNUNET_CONTAINER_BloomFilter *bf, BitIterator callback, void *arg, const struct GNUNET_HashCode *key)
Call an iterator for each bit that the bloomfilter must test or set for this element.
static bool testBit(char *bitArray, unsigned int bitIdx)
Checks if a bit is active in the bitArray.
static enum GNUNET_GenericReturnValue decrementBitCallback(void *cls, const struct GNUNET_CONTAINER_BloomFilter *bf, unsigned int bit)
Callback: decrement bit.
static struct Experiment * e
static int res
struct GNUNET_HashCode key
The key used in the DHT.
static struct GNUNET_FS_DownloadContext * dc
static char * filename
uint32_t data
The data value.
static char * value
Value of the record to add/remove.
static struct GNUNET_DISK_FileHandle * fh
File handle to STDIN, for reading restart/quit commands.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_bloomfilter_or(struct GNUNET_CONTAINER_BloomFilter *bf, const char *data, size_t size)
"or" the entries of the given raw data array with the data of the given Bloom filter.
struct GNUNET_CONTAINER_BloomFilter * GNUNET_CONTAINER_bloomfilter_load(const char *filename, size_t size, unsigned int k)
Load a Bloom filter from a file.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_bloomfilter_get_raw_data(const struct GNUNET_CONTAINER_BloomFilter *bf, char *data, size_t size)
Copy the raw data of this Bloom filter into the given data array.
void GNUNET_CONTAINER_bloomfilter_resize(struct GNUNET_CONTAINER_BloomFilter *bf, GNUNET_CONTAINER_HashCodeIterator iterator, void *iterator_cls, size_t size, unsigned int k)
Resize a bloom filter.
enum GNUNET_GenericReturnValue GNUNET_CONTAINER_bloomfilter_or2(struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_CONTAINER_BloomFilter *to_or)
"or" the entries of the given raw data array with the data of the given Bloom filter.
void GNUNET_CONTAINER_bloomfilter_add(struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_HashCode *e)
Add an element to the filter.
bool GNUNET_CONTAINER_bloomfilter_test(const struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_HashCode *e)
Test if an element is in the filter.
struct GNUNET_CONTAINER_BloomFilter * GNUNET_CONTAINER_bloomfilter_copy(const struct GNUNET_CONTAINER_BloomFilter *bf)
Create a copy of a bloomfilter.
void GNUNET_CONTAINER_bloomfilter_clear(struct GNUNET_CONTAINER_BloomFilter *bf)
Reset a Bloom filter to empty.
struct GNUNET_CONTAINER_BloomFilter * GNUNET_CONTAINER_bloomfilter_init(const char *data, size_t size, unsigned int k)
Create a Bloom filter from raw bits.
int(* GNUNET_CONTAINER_HashCodeIterator)(void *cls, struct GNUNET_HashCode *next)
Iterator over struct GNUNET_HashCode.
size_t GNUNET_CONTAINER_bloomfilter_get_size(const struct GNUNET_CONTAINER_BloomFilter *bf)
Get size of the bloom filter.
void GNUNET_CONTAINER_bloomfilter_remove(struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_HashCode *e)
Remove an element from the filter.
void GNUNET_CONTAINER_bloomfilter_free(struct GNUNET_CONTAINER_BloomFilter *bf)
Free the space associated with a filter in memory, flush to drive if needed (do not free the space on...
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
Definition: disk.c:1235
enum GNUNET_GenericReturnValue GNUNET_DISK_file_test(const char *fil)
Check that fil corresponds to a filename (of a file that exists and that is not a directory).
Definition: disk.c:482
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
Definition: disk.c:686
off_t GNUNET_DISK_file_seek(const struct GNUNET_DISK_FileHandle *h, off_t offset, enum GNUNET_DISK_Seek whence)
Move the read/write pointer in a file.
Definition: disk.c:206
enum GNUNET_GenericReturnValue GNUNET_DISK_handle_invalid(const struct GNUNET_DISK_FileHandle *h)
Checks whether a handle is invalid.
Definition: disk.c:186
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1306
ssize_t GNUNET_DISK_file_read(const struct GNUNET_DISK_FileHandle *h, void *result, size_t len)
Read the contents of a binary file into a buffer.
Definition: disk.c:622
enum GNUNET_GenericReturnValue GNUNET_DISK_file_handle_size(struct GNUNET_DISK_FileHandle *fh, off_t *size)
Get the size of an open file.
Definition: disk.c:193
@ GNUNET_DISK_OPEN_CREATE
Create file if it doesn't exist.
@ GNUNET_DISK_OPEN_READWRITE
Open the file for both reading and writing.
@ GNUNET_DISK_PERM_USER_READ
Owner can read.
@ GNUNET_DISK_PERM_USER_WRITE
Owner can write.
@ GNUNET_DISK_SEEK_SET
Seek an absolute position (from the start of the file).
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:41
static int iterator(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Iterator over hash map entries.
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
size_t GNUNET_CONTAINER_bloomfilter_get_element_addresses(const struct GNUNET_CONTAINER_BloomFilter *bf)
Get the number of the addresses set per element in the bloom filter.
GNUNET_GenericReturnValue
Named constants for return values.
Definition: gnunet_common.h:96
@ GNUNET_OK
Definition: gnunet_common.h:99
@ GNUNET_YES
@ GNUNET_NO
Definition: gnunet_common.h:98
@ GNUNET_SYSERR
Definition: gnunet_common.h:97
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_malloc_large(size)
Wrapper around malloc.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
static unsigned int size
Size of the "table".
Definition: peer.c:67
#define _(String)
GNU gettext support macro.
Definition: platform.h:177
size_t bitArraySize
Size of bitArray in bytes.
unsigned int addressesPerElement
How many bits we set for each stored element.
struct GNUNET_DISK_FileHandle * fh
The bit counter file on disk.
char * bitArray
The actual bloomfilter bit array.
char * filename
Filename of the filter.
Handle used to access files (and pipes).
A 512-bit hashcode.