fixed allocator handling
diff --git a/tuple/include/theta_update_sketch_base_impl.hpp b/tuple/include/theta_update_sketch_base_impl.hpp
index 8fdb3d8..bbf845b 100644
--- a/tuple/include/theta_update_sketch_base_impl.hpp
+++ b/tuple/include/theta_update_sketch_base_impl.hpp
@@ -69,7 +69,7 @@
template<typename EN, typename EK, typename A>
theta_update_sketch_base<EN, EK, A>::theta_update_sketch_base(theta_update_sketch_base&& other) noexcept:
-allocator_(other.allocator_),
+allocator_(std::move(other.allocator_)),
is_empty_(other.is_empty_),
lg_cur_size_(other.lg_cur_size_),
lg_nom_size_(other.lg_nom_size_),
diff --git a/tuple/include/tuple_sketch.hpp b/tuple/include/tuple_sketch.hpp
index 2292937..1cbd243 100644
--- a/tuple/include/tuple_sketch.hpp
+++ b/tuple/include/tuple_sketch.hpp
@@ -444,19 +444,21 @@
// for deserialize
class deleter_of_summaries {
public:
- deleter_of_summaries(uint32_t num, bool destroy): num(num), destroy(destroy) {}
- void set_destroy(bool destroy) { this->destroy = destroy; }
+ deleter_of_summaries(uint32_t num, bool destroy, const Allocator& allocator):
+ allocator_(allocator), num_(num), destroy_(destroy) {}
+ void set_destroy(bool destroy) { destroy_ = destroy; }
void operator() (Summary* ptr) const {
if (ptr != nullptr) {
- if (destroy) {
- for (uint32_t i = 0; i < num; ++i) ptr[i].~Summary();
+ if (destroy_) {
+ for (uint32_t i = 0; i < num_; ++i) ptr[i].~Summary();
}
- Allocator().deallocate(ptr, num);
+ allocator_.deallocate(ptr, num_);
}
}
private:
- uint32_t num;
- bool destroy;
+ Allocator allocator_;
+ uint32_t num_;
+ bool destroy_;
};
virtual void print_specifics(std::basic_ostream<char>& os) const;
diff --git a/tuple/include/tuple_sketch_impl.hpp b/tuple/include/tuple_sketch_impl.hpp
index 63552d7..52e2ebf 100644
--- a/tuple/include/tuple_sketch_impl.hpp
+++ b/tuple/include/tuple_sketch_impl.hpp
@@ -470,7 +470,7 @@
std::vector<Entry, AllocEntry> entries(alloc);
if (!is_empty) {
entries.reserve(num_entries);
- std::unique_ptr<S, deleter_of_summaries> summary(alloc.allocate(1), deleter_of_summaries(1, false));
+ std::unique_ptr<S, deleter_of_summaries> summary(alloc.allocate(1), deleter_of_summaries(1, false, allocator));
for (size_t i = 0; i < num_entries; ++i) {
uint64_t key;
is.read(reinterpret_cast<char*>(&key), sizeof(uint64_t));
@@ -533,7 +533,7 @@
std::vector<Entry, AllocEntry> entries(alloc);
if (!is_empty) {
entries.reserve(num_entries);
- std::unique_ptr<S, deleter_of_summaries> summary(alloc.allocate(1), deleter_of_summaries(1, false));
+ std::unique_ptr<S, deleter_of_summaries> summary(alloc.allocate(1), deleter_of_summaries(1, false, allocator));
for (size_t i = 0; i < num_entries; ++i) {
uint64_t key;
ptr += copy_from_mem(ptr, &key, sizeof(key));