You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by al...@apache.org on 2020/08/14 23:46:42 UTC

[incubator-datasketches-cpp] 01/07: allocation fix

This is an automated email from the ASF dual-hosted git repository.

alsay pushed a commit to branch tuple_sketch
in repository https://gitbox.apache.org/repos/asf/incubator-datasketches-cpp.git

commit 99cc63939914b6457de6f71b84c4957f09ef16c0
Author: AlexanderSaydakov <Al...@users.noreply.github.com>
AuthorDate: Wed Aug 12 15:29:33 2020 -0700

    allocation fix
---
 tuple/include/theta_update_sketch_base_impl.hpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tuple/include/theta_update_sketch_base_impl.hpp b/tuple/include/theta_update_sketch_base_impl.hpp
index cf6b46d..1cf88fb 100644
--- a/tuple/include/theta_update_sketch_base_impl.hpp
+++ b/tuple/include/theta_update_sketch_base_impl.hpp
@@ -59,7 +59,7 @@ entries_(nullptr)
     entries_ = allocator_.allocate(size);
     for (size_t i = 0; i < size; ++i) {
       if (EK()(other.entries_[i]) != 0) {
-        entries_[i] = other.entries_[i];
+        new (&entries_[i]) EN(other.entries_[i]);
       } else {
         EK()(entries_[i]) = 0;
       }
@@ -212,7 +212,7 @@ template<typename EN, typename EK, typename A>
 void theta_update_sketch_base<EN, EK, A>::rebuild() {
   const size_t size = 1 << lg_cur_size_;
   const uint32_t pivot = (1 << lg_nom_size_) + size - num_entries_;
-  std::nth_element(&entries_[0], &entries_[pivot], &entries_[size], comparator());
+  std::nth_element(entries_, entries_ + pivot, entries_ + size, comparator());
   this->theta_ = EK()(entries_[pivot]);
   EN* old_entries = entries_;
   entries_ = allocator_.allocate(size);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org