#include <string>
#include <vector>
+#include "include/mempool.h"
#include "include/encoding.h"
#include "common/Formatter.h"
0x80 //10000000
};
+MEMPOOL_DECLARE_FACTORY(unsigned char, byte, bloom_filter);
class bloom_filter
{
void init() {
generate_unique_salt();
if (table_size_) {
- bit_table_ = new cell_type[table_size_];
+ bit_table_ = mempool::bloom_filter::alloc_byte.allocate(table_size_);
std::fill_n(bit_table_, table_size_, 0x00);
} else {
bit_table_ = NULL;
bloom_filter& operator = (const bloom_filter& filter)
{
if (this != &filter) {
+ if (bit_table_) {
+ mempool::bloom_filter::alloc_byte.deallocate(bit_table_, table_size_);
+ }
salt_count_ = filter.salt_count_;
table_size_ = filter.table_size_;
insert_count_ = filter.insert_count_;
target_element_count_ = filter.target_element_count_;
random_seed_ = filter.random_seed_;
- delete[] bit_table_;
- bit_table_ = new cell_type[table_size_];
+ bit_table_ = mempool::bloom_filter::alloc_byte.allocate(table_size_);
std::copy(filter.bit_table_, filter.bit_table_ + table_size_, bit_table_);
salt_ = filter.salt_;
}
virtual ~bloom_filter()
{
- delete[] bit_table_;
+ mempool::bloom_filter::alloc_byte.deallocate(bit_table_, table_size_);
}
inline bool operator!() const
return false;
}
- cell_type* tmp = new cell_type[new_table_size];
+ cell_type* tmp = mempool::bloom_filter::alloc_byte.allocate(new_table_size);
std::copy(bit_table_, bit_table_ + (new_table_size), tmp);
cell_type* itr = bit_table_ + (new_table_size);
cell_type* end = bit_table_ + (original_table_size);
itr_tmp = tmp;
}
- delete[] bit_table_;
+ mempool::bloom_filter::alloc_byte.deallocate(bit_table_, table_size_);
bit_table_ = tmp;
size_list.push_back(new_table_size);
table_size_ = new_table_size;
#include <typeinfo>
#include <common/Formatter.h>
+#include "include/assert.h"
/*
// Use this for any type that is contained by a container (unless it
// is a class you defined; see below).
+#define MEMPOOL_DECLARE_FACTORY(obj, factoryname, pool) \
+ namespace mempool { \
+ namespace pool { \
+ extern pool_allocator<obj> alloc_##factoryname; \
+ } \
+ }
+
#define MEMPOOL_DEFINE_FACTORY(obj, factoryname, pool) \
namespace mempool { \
namespace pool { \