- Allocate buffer large enough to contain UNIX_PATH_MAX size pathnames in case of...
[oweals/gnunet.git] / src / util / container_bloomfilter.c
index 579c1261db5b2a36af741d43ae9a1000def785d7..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.
@@ -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);