GNUnet  0.11.x
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 
92 size_t
94  const struct GNUNET_CONTAINER_BloomFilter *bf)
95 {
96  if (bf == NULL)
97  return 0;
98  return bf->addressesPerElement;
99 }
100 
101 
108 size_t
110  const struct GNUNET_CONTAINER_BloomFilter *bf)
111 {
112  if (bf == NULL)
113  return 0;
114  return bf->bitArraySize;
115 }
116 
117 
126  const struct GNUNET_CONTAINER_BloomFilter *bf)
127 {
129  bf->bitArraySize,
130  bf->addressesPerElement);
131 }
132 
133 
141 static void
142 setBit (char *bitArray, unsigned int bitIdx)
143 {
144  size_t arraySlot;
145  unsigned int targetBit;
146 
147  arraySlot = bitIdx / 8;
148  targetBit = (1L << (bitIdx % 8));
149  bitArray[arraySlot] |= targetBit;
150 }
151 
152 
160 static void
161 clearBit (char *bitArray, unsigned int bitIdx)
162 {
163  size_t slot;
164  unsigned int targetBit;
165 
166  slot = bitIdx / 8;
167  targetBit = (1L << (bitIdx % 8));
168  bitArray[slot] = bitArray[slot] & (~targetBit);
169 }
170 
171 
179 static int
180 testBit (char *bitArray, unsigned int bitIdx)
181 {
182  size_t slot;
183  unsigned int targetBit;
184 
185  slot = bitIdx / 8;
186  targetBit = (1L << (bitIdx % 8));
187  if (bitArray[slot] & targetBit)
188  return GNUNET_YES;
189  else
190  return GNUNET_NO;
191 }
192 
193 
203 static void
205  unsigned int bitIdx,
206  const struct GNUNET_DISK_FileHandle *fh)
207 {
208  off_t fileSlot;
209  unsigned char value;
210  unsigned int high;
211  unsigned int low;
212  unsigned int targetLoc;
213 
214  setBit (bitArray, bitIdx);
216  return;
217  /* Update the counter file on disk */
218  fileSlot = bitIdx / 2;
219  targetLoc = bitIdx % 2;
220 
221  GNUNET_assert (fileSlot ==
223  if (1 != GNUNET_DISK_file_read (fh, &value, 1))
224  value = 0;
225  low = value & 0xF;
226  high = (value & (~0xF)) >> 4;
227 
228  if (targetLoc == 0)
229  {
230  if (low < 0xF)
231  low++;
232  }
233  else
234  {
235  if (high < 0xF)
236  high++;
237  }
238  value = ((high << 4) | low);
239  GNUNET_assert (fileSlot ==
242 }
243 
244 
253 static void
255  unsigned int bitIdx,
256  const struct GNUNET_DISK_FileHandle *fh)
257 {
258  off_t fileslot;
259  unsigned char value;
260  unsigned int high;
261  unsigned int low;
262  unsigned int targetLoc;
263 
265  return; /* cannot decrement! */
266  /* Each char slot in the counter file holds two 4 bit counters */
267  fileslot = bitIdx / 2;
268  targetLoc = bitIdx % 2;
269  if (GNUNET_SYSERR ==
271  {
273  return;
274  }
275  if (1 != GNUNET_DISK_file_read (fh, &value, 1))
276  value = 0;
277  low = value & 0xF;
278  high = (value & 0xF0) >> 4;
279 
280  /* decrement, but once we have reached the max, never go back! */
281  if (targetLoc == 0)
282  {
283  if ((low > 0) && (low < 0xF))
284  low--;
285  if (low == 0)
286  {
287  clearBit (bitArray, bitIdx);
288  }
289  }
290  else
291  {
292  if ((high > 0) && (high < 0xF))
293  high--;
294  if (high == 0)
295  {
296  clearBit (bitArray, bitIdx);
297  }
298  }
299  value = ((high << 4) | low);
300  if (GNUNET_SYSERR ==
302  {
304  return;
305  }
307 }
308 
309 
310 #define BUFFSIZE 65536
311 
319 static int
321 {
322  char buffer[BUFFSIZE];
323  size_t bytesleft = size;
324  int res = 0;
325 
327  return GNUNET_SYSERR;
328  memset (buffer, 0, sizeof(buffer));
330  while (bytesleft > 0)
331  {
332  if (bytesleft > sizeof(buffer))
333  {
334  res = GNUNET_DISK_file_write (fh, buffer, sizeof(buffer));
335  if (res >= 0)
336  bytesleft -= res;
337  }
338  else
339  {
340  res = GNUNET_DISK_file_write (fh, buffer, bytesleft);
341  if (res >= 0)
342  bytesleft -= res;
343  }
344  if (GNUNET_SYSERR == res)
345  return GNUNET_SYSERR;
346  }
347  return GNUNET_OK;
348 }
349 
350 
351 /* ************** GNUNET_CONTAINER_BloomFilter iterator ********* */
352 
363 typedef int (*BitIterator) (void *cls,
364  const struct GNUNET_CONTAINER_BloomFilter *bf,
365  unsigned int bit);
366 
367 
377 static void
379  BitIterator callback,
380  void *arg,
381  const struct GNUNET_HashCode *key)
382 {
383  struct GNUNET_HashCode tmp = *key;
384  int bitCount;
385  unsigned int slot = 0;
386 
387  bitCount = bf->addressesPerElement;
388  GNUNET_assert (bf->bitArraySize > 0);
389  GNUNET_assert (bf->bitArraySize * 8LL > bf->bitArraySize);
390  while (bitCount > 0)
391  {
392  while ( (0 != bitCount) &&
393  (slot < (sizeof(struct GNUNET_HashCode) / sizeof(uint32_t))) )
394  {
395  if (GNUNET_YES !=
396  callback (arg,
397  bf,
398  ntohl ((((uint32_t *) &tmp)[slot]))
399  % ((bf->bitArraySize * 8LL))))
400  return;
401  slot++;
402  bitCount--;
403  }
404  if (0 == bitCount)
405  break;
406  GNUNET_CRYPTO_hash (&tmp,
407  sizeof(tmp),
408  &tmp);
409  slot = 0;
410  }
411 }
412 
413 
422 static int
424  const struct GNUNET_CONTAINER_BloomFilter *bf,
425  unsigned int bit)
426 {
427  struct GNUNET_CONTAINER_BloomFilter *b = cls;
428 
429  incrementBit (b->bitArray, bit, bf->fh);
430  return GNUNET_YES;
431 }
432 
433 
442 static int
444  const struct GNUNET_CONTAINER_BloomFilter *bf,
445  unsigned int bit)
446 {
447  struct GNUNET_CONTAINER_BloomFilter *b = cls;
448 
449  decrementBit (b->bitArray, bit, bf->fh);
450  return GNUNET_YES;
451 }
452 
453 
462 static int
463 testBitCallback (void *cls,
464  const struct GNUNET_CONTAINER_BloomFilter *bf,
465  unsigned int bit)
466 {
467  int *arg = cls;
468 
469  if (GNUNET_NO == testBit (bf->bitArray, bit))
470  {
471  *arg = GNUNET_NO;
472  return GNUNET_NO;
473  }
474  return GNUNET_YES;
475 }
476 
477 
478 /* *********************** INTERFACE **************** */
479 
493  size_t size,
494  unsigned int k)
495 {
496  struct GNUNET_CONTAINER_BloomFilter *bf;
497  char *rbuff;
498  off_t pos;
499  int i;
500  size_t ui;
501  off_t fsize;
502  int must_read;
503 
504  GNUNET_assert (NULL != filename);
505  if ((k == 0) || (size == 0))
506  return NULL;
507  if (size < BUFFSIZE)
508  size = BUFFSIZE;
509  ui = 1;
510  while ((ui < size) && (ui * 2 > ui))
511  ui *= 2;
512  size = ui; /* make sure it's a power of 2 */
513 
515  /* Try to open a bloomfilter file */
521  if (NULL != bf->fh)
522  {
523  /* file existed, try to read it! */
524  must_read = GNUNET_YES;
525  if (GNUNET_OK != GNUNET_DISK_file_handle_size (bf->fh, &fsize))
526  {
528  GNUNET_free (bf);
529  return NULL;
530  }
531  if (0 == fsize)
532  {
533  /* found existing empty file, just overwrite */
534  if (GNUNET_OK != make_empty_file (bf->fh, size * 4LL))
535  {
538  GNUNET_free (bf);
539  return NULL;
540  }
541  }
542  else if (fsize != ((off_t) size) * 4LL)
543  {
544  GNUNET_log (
546  _ (
547  "Size of file on disk is incorrect for this Bloom filter (want %llu, have %llu)\n"),
548  (unsigned long long) (size * 4LL),
549  (unsigned long long) fsize);
551  GNUNET_free (bf);
552  return NULL;
553  }
554  }
555  else
556  {
557  /* file did not exist, don't read, just create */
558  must_read = GNUNET_NO;
564  if (NULL == bf->fh)
565  {
566  GNUNET_free (bf);
567  return NULL;
568  }
569  if (GNUNET_OK != make_empty_file (bf->fh, size * 4LL))
570  {
573  GNUNET_free (bf);
574  return NULL;
575  }
576  }
578  /* Alloc block */
580  if (NULL == bf->bitArray)
581  {
582  if (NULL != bf->fh)
584  GNUNET_free (bf->filename);
585  GNUNET_free (bf);
586  return NULL;
587  }
588  bf->bitArraySize = size;
589  bf->addressesPerElement = k;
590  if (GNUNET_YES != must_read)
591  return bf; /* already done! */
592  /* Read from the file what bits we can */
593  rbuff = GNUNET_malloc (BUFFSIZE);
594  pos = 0;
595  while (pos < ((off_t) size) * 8LL)
596  {
597  int res;
598 
599  res = GNUNET_DISK_file_read (bf->fh, rbuff, BUFFSIZE);
600  if (res == -1)
601  {
603  GNUNET_free (rbuff);
604  GNUNET_free (bf->filename);
606  GNUNET_free (bf);
607  return NULL;
608  }
609  if (res == 0)
610  break; /* is ok! we just did not use that many bits yet */
611  for (i = 0; i < res; i++)
612  {
613  if ((rbuff[i] & 0x0F) != 0)
614  setBit (bf->bitArray, pos + i * 2);
615  if ((rbuff[i] & 0xF0) != 0)
616  setBit (bf->bitArray, pos + i * 2 + 1);
617  }
618  if (res < BUFFSIZE)
619  break;
620  pos += BUFFSIZE * 2; /* 2 bits per byte in the buffer */
621  }
622  GNUNET_free (rbuff);
623  return bf;
624 }
625 
626 
642  size_t size,
643  unsigned int k)
644 {
645  struct GNUNET_CONTAINER_BloomFilter *bf;
646 
647  if ((0 == k) || (0 == size))
648  return NULL;
650  bf->filename = NULL;
651  bf->fh = NULL;
653  if (NULL == bf->bitArray)
654  {
655  GNUNET_free (bf);
656  return NULL;
657  }
658  bf->bitArraySize = size;
659  bf->addressesPerElement = k;
660  if (NULL != data)
662  return bf;
663 }
664 
665 
675 int
677  const struct GNUNET_CONTAINER_BloomFilter *bf,
678  char *data,
679  size_t size)
680 {
681  if (NULL == bf)
682  return GNUNET_SYSERR;
683  if (bf->bitArraySize != size)
684  return GNUNET_SYSERR;
686  return GNUNET_OK;
687 }
688 
689 
697 void
699 {
700  if (NULL == bf)
701  return;
702  if (bf->fh != NULL)
704  GNUNET_free (bf->filename);
705  GNUNET_free (bf->bitArray);
706  GNUNET_free (bf);
707 }
708 
709 
715 void
717 {
718  if (NULL == bf)
719  return;
720 
721  memset (bf->bitArray, 0, bf->bitArraySize);
722  if (bf->filename != NULL)
723  make_empty_file (bf->fh, bf->bitArraySize * 4LL);
724 }
725 
726 
734 int
736  const struct GNUNET_CONTAINER_BloomFilter *bf,
737  const struct GNUNET_HashCode *e)
738 {
739  int res;
740 
741  if (NULL == bf)
742  return GNUNET_YES;
743  res = GNUNET_YES;
744  iterateBits (bf, &testBitCallback, &res, e);
745  return res;
746 }
747 
748 
755 void
757  const struct GNUNET_HashCode *e)
758 {
759  if (NULL == bf)
760  return;
761  iterateBits (bf, &incrementBitCallback, bf, e);
762 }
763 
764 
775 int
777  const char *data,
778  size_t size)
779 {
780  unsigned int i;
781  unsigned int n;
782  unsigned long long *fc;
783  const unsigned long long *dc;
784 
785  if (NULL == bf)
786  return GNUNET_YES;
787  if (bf->bitArraySize != size)
788  return GNUNET_SYSERR;
789  fc = (unsigned long long *) bf->bitArray;
790  dc = (const unsigned long long *) data;
791  n = size / sizeof(unsigned long long);
792 
793  for (i = 0; i < n; i++)
794  fc[i] |= dc[i];
795  for (i = n * sizeof(unsigned long long); i < size; i++)
796  bf->bitArray[i] |= data[i];
797  return GNUNET_OK;
798 }
799 
800 
811 int
813  struct GNUNET_CONTAINER_BloomFilter *bf,
814  const struct GNUNET_CONTAINER_BloomFilter *to_or)
815 {
816  unsigned int i;
817  unsigned int n;
818  unsigned long long *fc;
819  const unsigned long long *dc;
820  size_t size;
821 
822  if (NULL == bf)
823  return GNUNET_OK;
824  if (bf->bitArraySize != to_or->bitArraySize)
825  {
826  GNUNET_break (0);
827  return GNUNET_SYSERR;
828  }
829  size = bf->bitArraySize;
830  fc = (unsigned long long *) bf->bitArray;
831  dc = (const unsigned long long *) to_or->bitArray;
832  n = size / sizeof(unsigned long long);
833 
834  for (i = 0; i < n; i++)
835  fc[i] |= dc[i];
836  for (i = n * sizeof(unsigned long long); i < size; i++)
837  bf->bitArray[i] |= to_or->bitArray[i];
838  return GNUNET_OK;
839 }
840 
841 
848 void
850  const struct GNUNET_HashCode *e)
851 {
852  if (NULL == bf)
853  return;
854  if (NULL == bf->filename)
855  return;
856  iterateBits (bf, &decrementBitCallback, bf, e);
857 }
858 
859 
871 void
874  void *iterator_cls,
875  size_t size,
876  unsigned int k)
877 {
878  struct GNUNET_HashCode hc;
879  unsigned int i;
880 
881  GNUNET_free (bf->bitArray);
882  i = 1;
883  while (i < size)
884  i *= 2;
885  size = i; /* make sure it's a power of 2 */
886  bf->addressesPerElement = k;
887  bf->bitArraySize = size;
888  bf->bitArray = GNUNET_malloc (size);
889  if (NULL != bf->filename)
890  make_empty_file (bf->fh, bf->bitArraySize * 4LL);
891  while (GNUNET_YES == iterator (iterator_cls, &hc))
893 }
894 
895 
896 /* end of container_bloomfilter.c */
static int incrementBitCallback(void *cls, const struct GNUNET_CONTAINER_BloomFilter *bf, unsigned int bit)
Callback: increment bit.
#define BUFFSIZE
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.
int(* 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 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.
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 int make_empty_file(const struct GNUNET_DISK_FileHandle *fh, size_t size)
Creates a file filled with zeroes.
static int testBitCallback(void *cls, const struct GNUNET_CONTAINER_BloomFilter *bf, unsigned int bit)
Callback: test if all bits are set.
static int decrementBitCallback(void *cls, const struct GNUNET_CONTAINER_BloomFilter *bf, unsigned int bit)
Callback: decrement bit.
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.
static int testBit(char *bitArray, unsigned int bitIdx)
Checks if a bit is active in the bitArray.
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.
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
@ GNUNET_OK
Definition: gnunet_common.h:95
@ GNUNET_YES
Definition: gnunet_common.h:97
@ GNUNET_NO
Definition: gnunet_common.h:94
@ GNUNET_SYSERR
Definition: gnunet_common.h:93
int 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.
int GNUNET_CONTAINER_bloomfilter_get_raw_data(const struct GNUNET_CONTAINER_BloomFilter *bf, char *data, size_t size)
Copy the raw data of this bloomfilter 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.
int 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.
struct GNUNET_CONTAINER_BloomFilter * GNUNET_CONTAINER_bloomfilter_copy(const struct GNUNET_CONTAINER_BloomFilter *bf)
Copy an existing memory.
void GNUNET_CONTAINER_bloomfilter_clear(struct GNUNET_CONTAINER_BloomFilter *bf)
Reset a bloom filter to empty.
int 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_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_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.