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 ==
241  GNUNET_assert (1 == GNUNET_DISK_file_write (fh, &value, 1));
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  }
306  GNUNET_assert (1 == GNUNET_DISK_file_write (fh, &value, 1));
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[2];
384  int bitCount;
385  unsigned int round;
386  unsigned int slot = 0;
387 
388  bitCount = bf->addressesPerElement;
389  tmp[0] = *key;
390  round = 0;
391  GNUNET_assert (bf->bitArraySize > 0);
392  GNUNET_assert (bf->bitArraySize * 8LL > bf->bitArraySize);
393  while (bitCount > 0)
394  {
395  while (slot < (sizeof(struct GNUNET_HashCode) / sizeof(uint32_t)))
396  {
397  if (GNUNET_YES !=
398  callback (arg,
399  bf,
400  ntohl ((((uint32_t *) &tmp[round & 1])[slot]))
401  % ((bf->bitArraySize * 8LL))))
402  return;
403  slot++;
404  bitCount--;
405  if (bitCount == 0)
406  break;
407  }
408  if (bitCount > 0)
409  {
410  GNUNET_CRYPTO_hash (&tmp[round & 1],
411  sizeof(struct GNUNET_HashCode),
412  &tmp[(round + 1) & 1]);
413  round++;
414  slot = 0;
415  }
416  }
417 }
418 
419 
428 static int
430  const struct GNUNET_CONTAINER_BloomFilter *bf,
431  unsigned int bit)
432 {
433  struct GNUNET_CONTAINER_BloomFilter *b = cls;
434 
435  incrementBit (b->bitArray, bit, bf->fh);
436  return GNUNET_YES;
437 }
438 
439 
448 static int
450  const struct GNUNET_CONTAINER_BloomFilter *bf,
451  unsigned int bit)
452 {
453  struct GNUNET_CONTAINER_BloomFilter *b = cls;
454 
455  decrementBit (b->bitArray, bit, bf->fh);
456  return GNUNET_YES;
457 }
458 
459 
468 static int
469 testBitCallback (void *cls,
470  const struct GNUNET_CONTAINER_BloomFilter *bf,
471  unsigned int bit)
472 {
473  int *arg = cls;
474 
475  if (GNUNET_NO == testBit (bf->bitArray, bit))
476  {
477  *arg = GNUNET_NO;
478  return GNUNET_NO;
479  }
480  return GNUNET_YES;
481 }
482 
483 
484 /* *********************** INTERFACE **************** */
485 
499  size_t size,
500  unsigned int k)
501 {
502  struct GNUNET_CONTAINER_BloomFilter *bf;
503  char *rbuff;
504  off_t pos;
505  int i;
506  size_t ui;
507  off_t fsize;
508  int must_read;
509 
510  GNUNET_assert (NULL != filename);
511  if ((k == 0) || (size == 0))
512  return NULL;
513  if (size < BUFFSIZE)
514  size = BUFFSIZE;
515  ui = 1;
516  while ((ui < size) && (ui * 2 > ui))
517  ui *= 2;
518  size = ui; /* make sure it's a power of 2 */
519 
521  /* Try to open a bloomfilter file */
522  if (GNUNET_YES == GNUNET_DISK_file_test (filename))
523  bf->fh = GNUNET_DISK_file_open (filename,
527  if (NULL != bf->fh)
528  {
529  /* file existed, try to read it! */
530  must_read = GNUNET_YES;
531  if (GNUNET_OK != GNUNET_DISK_file_handle_size (bf->fh, &fsize))
532  {
534  GNUNET_free (bf);
535  return NULL;
536  }
537  if (0 == fsize)
538  {
539  /* found existing empty file, just overwrite */
540  if (GNUNET_OK != make_empty_file (bf->fh, size * 4LL))
541  {
544  GNUNET_free (bf);
545  return NULL;
546  }
547  }
548  else if (fsize != ((off_t) size) * 4LL)
549  {
550  GNUNET_log (
552  _ (
553  "Size of file on disk is incorrect for this Bloom filter (want %llu, have %llu)\n"),
554  (unsigned long long) (size * 4LL),
555  (unsigned long long) fsize);
557  GNUNET_free (bf);
558  return NULL;
559  }
560  }
561  else
562  {
563  /* file did not exist, don't read, just create */
564  must_read = GNUNET_NO;
565  bf->fh = GNUNET_DISK_file_open (filename,
570  if (NULL == bf->fh)
571  {
572  GNUNET_free (bf);
573  return NULL;
574  }
575  if (GNUNET_OK != make_empty_file (bf->fh, size * 4LL))
576  {
579  GNUNET_free (bf);
580  return NULL;
581  }
582  }
583  bf->filename = GNUNET_strdup (filename);
584  /* Alloc block */
585  bf->bitArray = GNUNET_malloc_large (size);
586  if (NULL == bf->bitArray)
587  {
588  if (NULL != bf->fh)
590  GNUNET_free (bf->filename);
591  GNUNET_free (bf);
592  return NULL;
593  }
594  bf->bitArraySize = size;
595  bf->addressesPerElement = k;
596  if (GNUNET_YES != must_read)
597  return bf; /* already done! */
598  /* Read from the file what bits we can */
599  rbuff = GNUNET_malloc (BUFFSIZE);
600  pos = 0;
601  while (pos < ((off_t) size) * 8LL)
602  {
603  int res;
604 
605  res = GNUNET_DISK_file_read (bf->fh, rbuff, BUFFSIZE);
606  if (res == -1)
607  {
609  GNUNET_free (rbuff);
610  GNUNET_free (bf->filename);
612  GNUNET_free (bf);
613  return NULL;
614  }
615  if (res == 0)
616  break; /* is ok! we just did not use that many bits yet */
617  for (i = 0; i < res; i++)
618  {
619  if ((rbuff[i] & 0x0F) != 0)
620  setBit (bf->bitArray, pos + i * 2);
621  if ((rbuff[i] & 0xF0) != 0)
622  setBit (bf->bitArray, pos + i * 2 + 1);
623  }
624  if (res < BUFFSIZE)
625  break;
626  pos += BUFFSIZE * 2; /* 2 bits per byte in the buffer */
627  }
628  GNUNET_free (rbuff);
629  return bf;
630 }
631 
632 
648  size_t size,
649  unsigned int k)
650 {
651  struct GNUNET_CONTAINER_BloomFilter *bf;
652 
653  if ((0 == k) || (0 == size))
654  return NULL;
656  bf->filename = NULL;
657  bf->fh = NULL;
658  bf->bitArray = GNUNET_malloc_large (size);
659  if (NULL == bf->bitArray)
660  {
661  GNUNET_free (bf);
662  return NULL;
663  }
664  bf->bitArraySize = size;
665  bf->addressesPerElement = k;
666  if (NULL != data)
667  GNUNET_memcpy (bf->bitArray, data, size);
668  return bf;
669 }
670 
671 
681 int
683  const struct GNUNET_CONTAINER_BloomFilter *bf,
684  char *data,
685  size_t size)
686 {
687  if (NULL == bf)
688  return GNUNET_SYSERR;
689  if (bf->bitArraySize != size)
690  return GNUNET_SYSERR;
691  GNUNET_memcpy (data, bf->bitArray, size);
692  return GNUNET_OK;
693 }
694 
695 
703 void
705 {
706  if (NULL == bf)
707  return;
708  if (bf->fh != NULL)
711  GNUNET_free (bf->bitArray);
712  GNUNET_free (bf);
713 }
714 
715 
721 void
723 {
724  if (NULL == bf)
725  return;
726 
727  memset (bf->bitArray, 0, bf->bitArraySize);
728  if (bf->filename != NULL)
729  make_empty_file (bf->fh, bf->bitArraySize * 4LL);
730 }
731 
732 
740 int
742  const struct GNUNET_CONTAINER_BloomFilter *bf,
743  const struct GNUNET_HashCode *e)
744 {
745  int res;
746 
747  if (NULL == bf)
748  return GNUNET_YES;
749  res = GNUNET_YES;
750  iterateBits (bf, &testBitCallback, &res, e);
751  return res;
752 }
753 
754 
761 void
763  const struct GNUNET_HashCode *e)
764 {
765  if (NULL == bf)
766  return;
767  iterateBits (bf, &incrementBitCallback, bf, e);
768 }
769 
770 
781 int
783  const char *data,
784  size_t size)
785 {
786  unsigned int i;
787  unsigned int n;
788  unsigned long long *fc;
789  const unsigned long long *dc;
790 
791  if (NULL == bf)
792  return GNUNET_YES;
793  if (bf->bitArraySize != size)
794  return GNUNET_SYSERR;
795  fc = (unsigned long long *) bf->bitArray;
796  dc = (const unsigned long long *) data;
797  n = size / sizeof(unsigned long long);
798 
799  for (i = 0; i < n; i++)
800  fc[i] |= dc[i];
801  for (i = n * sizeof(unsigned long long); i < size; i++)
802  bf->bitArray[i] |= data[i];
803  return GNUNET_OK;
804 }
805 
806 
817 int
819  struct GNUNET_CONTAINER_BloomFilter *bf,
820  const struct GNUNET_CONTAINER_BloomFilter *to_or)
821 {
822  unsigned int i;
823  unsigned int n;
824  unsigned long long *fc;
825  const unsigned long long *dc;
826  size_t size;
827 
828  if (NULL == bf)
829  return GNUNET_OK;
830  if (bf->bitArraySize != to_or->bitArraySize)
831  {
832  GNUNET_break (0);
833  return GNUNET_SYSERR;
834  }
835  size = bf->bitArraySize;
836  fc = (unsigned long long *) bf->bitArray;
837  dc = (const unsigned long long *) to_or->bitArray;
838  n = size / sizeof(unsigned long long);
839 
840  for (i = 0; i < n; i++)
841  fc[i] |= dc[i];
842  for (i = n * sizeof(unsigned long long); i < size; i++)
843  bf->bitArray[i] |= to_or->bitArray[i];
844  return GNUNET_OK;
845 }
846 
847 
854 void
856  const struct GNUNET_HashCode *e)
857 {
858  if (NULL == bf)
859  return;
860  if (NULL == bf->filename)
861  return;
862  iterateBits (bf, &decrementBitCallback, bf, e);
863 }
864 
865 
877 void
880  void *iterator_cls,
881  size_t size,
882  unsigned int k)
883 {
884  struct GNUNET_HashCode hc;
885  unsigned int i;
886 
887  GNUNET_free (bf->bitArray);
888  i = 1;
889  while (i < size)
890  i *= 2;
891  size = i; /* make sure it's a power of 2 */
892  bf->addressesPerElement = k;
893  bf->bitArraySize = size;
894  bf->bitArray = GNUNET_malloc (size);
895  if (NULL != bf->filename)
896  make_empty_file (bf->fh, bf->bitArraySize * 4LL);
897  while (GNUNET_YES == iterator (iterator_cls, &hc))
899 }
900 
901 
902 /* end of container_bloomfilter.c */
static int testBitCallback(void *cls, const struct GNUNET_CONTAINER_BloomFilter *bf, unsigned int bit)
Callback: test if all bits are set.
static int iterator(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Iterator over hash map entries.
int 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:544
struct GNUNET_CONTAINER_BloomFilter * GNUNET_CONTAINER_bloomfilter_init(const char *data, size_t size, unsigned int k)
Create a bloom filter from raw bits.
Create file if it doesn&#39;t exist.
void GNUNET_CONTAINER_bloomfilter_add(struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_HashCode *e)
Add an element to the filter.
int GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1345
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:732
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.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static int make_empty_file(const struct GNUNET_DISK_FileHandle *fh, size_t size)
Creates a file filled with zeroes.
unsigned int addressesPerElement
How many bits we set for each stored element.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define LOG_STRERROR_FILE(kind, syscall, filename)
size_t GNUNET_CONTAINER_bloomfilter_get_size(const struct GNUNET_CONTAINER_BloomFilter *bf)
Get size of the bloom filter.
static struct Experiment * e
#define GNUNET_NO
Definition: gnunet_common.h:78
char * filename
Filename of the filter.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static int incrementBitCallback(void *cls, const struct GNUNET_CONTAINER_BloomFilter *bf, unsigned int bit)
Callback: increment bit.
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:226
#define GNUNET_malloc_large(size)
Wrapper around malloc.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
int GNUNET_DISK_handle_invalid(const struct GNUNET_DISK_FileHandle *h)
Checks whether a handle is invalid.
Definition: disk.c:192
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.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
static void clearBit(char *bitArray, unsigned int bitIdx)
Clears a bit from bitArray.
void GNUNET_CONTAINER_bloomfilter_remove(struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_HashCode *e)
Remove an element from the filter.
static char * value
Value of the record to add/remove.
int GNUNET_CONTAINER_bloomfilter_test(const struct GNUNET_CONTAINER_BloomFilter *bf, const struct GNUNET_HashCode *e)
Test if an element is in the filter.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:48
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:820
size_t bitArraySize
Size of bitArray in bytes.
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.
struct GNUNET_CONTAINER_BloomFilter * GNUNET_CONTAINER_bloomfilter_load(const char *filename, size_t size, unsigned int k)
Load a bloom-filter from a file.
A 512-bit hashcode.
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 res
void GNUNET_CONTAINER_bloomfilter_clear(struct GNUNET_CONTAINER_BloomFilter *bf)
Reset a bloom filter to empty.
struct GNUNET_HashCode key
The key used in the DHT.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static unsigned int size
Size of the "table".
Definition: peer.c:67
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.
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.
char * bitArray
The actual bloomfilter bit array.
struct GNUNET_DISK_FileHandle * fh
The bit counter file on disk.
static void setBit(char *bitArray, unsigned int bitIdx)
Sets a bit active in the bitArray.
Seek an absolute position (from the start of the file).
int GNUNET_DISK_file_handle_size(struct GNUNET_DISK_FileHandle *fh, off_t *size)
Get the size of an open file.
Definition: disk.c:206
#define GNUNET_log(kind,...)
Open the file for both reading and writing.
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 int testBit(char *bitArray, unsigned int bitIdx)
Checks if a bit is active in the bitArray.
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GNUNET_CONTAINER_BloomFilter * GNUNET_CONTAINER_bloomfilter_copy(const struct GNUNET_CONTAINER_BloomFilter *bf)
Copy an existing memory.
int(* GNUNET_CONTAINER_HashCodeIterator)(void *cls, struct GNUNET_HashCode *next)
Iterator over struct GNUNET_HashCode.
#define BUFFSIZE
uint32_t data
The data value.
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:1268
Handle used to access files (and pipes).
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.
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...
#define GNUNET_malloc(size)
Wrapper around malloc.
static struct GNUNET_FS_DownloadContext * dc
#define GNUNET_free(ptr)
Wrapper around free.
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 ...