- Allocate buffer large enough to contain UNIX_PATH_MAX size pathnames in case of...
[oweals/gnunet.git] / src / util / container_bloomfilter.c
index 08a083df406d18b9b6600356d42fc62c584be71f..9554e0ec091e3e54cb6fddef004758db644e6d66 100644 (file)
@@ -79,6 +79,21 @@ struct GNUNET_CONTAINER_BloomFilter
 };
 
 
+/**
+ * Get the number of the addresses set per element in the bloom filter.
+ *
+ * @param bf the filter
+ * @return addresses set per element in the bf
+ */
+size_t
+GNUNET_CONTAINER_bloomfilter_get_element_addresses (const struct GNUNET_CONTAINER_BloomFilter
+                                       *bf)
+{
+  if (bf == NULL)
+    return 0;
+  return bf->addressesPerElement;
+}
+
 
 /**
  * Get size of the bloom filter.
@@ -181,7 +196,7 @@ static void
 incrementBit (char *bitArray, unsigned int bitIdx,
               const struct GNUNET_DISK_FileHandle *fh)
 {
-  OFF_T fileSlot;
+  off_t fileSlot;
   unsigned char value;
   unsigned int high;
   unsigned int low;
@@ -229,7 +244,7 @@ static void
 decrementBit (char *bitArray, unsigned int bitIdx,
               const struct GNUNET_DISK_FileHandle *fh)
 {
-  OFF_T fileslot;
+  off_t fileslot;
   unsigned char value;
   unsigned int high;
   unsigned int low;
@@ -462,10 +477,10 @@ GNUNET_CONTAINER_bloomfilter_load (const char *filename, size_t size,
 {
   struct GNUNET_CONTAINER_BloomFilter *bf;
   char *rbuff;
-  OFF_T pos;
+  off_t pos;
   int i;
   size_t ui;
-  OFF_T fsize;
+  off_t fsize;
   int must_read;
 
   GNUNET_assert (NULL != filename);
@@ -479,7 +494,7 @@ GNUNET_CONTAINER_bloomfilter_load (const char *filename, size_t size,
     ui *= 2;
   size = ui;                    /* make sure it's a power of 2 */
 
-  bf = GNUNET_malloc (sizeof (struct GNUNET_CONTAINER_BloomFilter));
+  bf = GNUNET_new (struct GNUNET_CONTAINER_BloomFilter);
   /* Try to open a bloomfilter file */
   if (GNUNET_YES == GNUNET_DISK_file_test (filename))
     bf->fh =
@@ -616,7 +631,7 @@ GNUNET_CONTAINER_bloomfilter_init (const char *data, size_t size,
 
   if ((0 == k) || (0 == size))
     return NULL;
-  bf = GNUNET_malloc (sizeof (struct GNUNET_CONTAINER_BloomFilter));
+  bf = GNUNET_new (struct GNUNET_CONTAINER_BloomFilter);
   bf->filename = NULL;
   bf->fh = NULL;
   bf->bitArray = GNUNET_malloc_large (size);