*/
#include "platform.h"
-#include "gnunet_common.h"
-#include "gnunet_container_lib.h"
-#include "gnunet_disk_lib.h"
+#include "gnunet_util_lib.h"
#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
};
+/**
+ * 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.
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;
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;
{
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);
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 =
}
bf->bitArraySize = size;
bf->addressesPerElement = k;
- if (GNUNET_YES != must_read)
- return bf; /* already done! */
+ if (GNUNET_YES != must_read)
+ return bf; /* already done! */
/* Read from the file what bits we can */
rbuff = GNUNET_malloc (BUFFSIZE);
pos = 0;
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);