proost commented on code in PR #575:
URL: https://github.com/apache/datasketches-cpp/pull/575#discussion_r4572249173


##########
req/include/req_compactor_impl.hpp:
##########
@@ -211,13 +219,14 @@ void req_compactor<T, C, A>::grow(uint32_t new_capacity) {
     new (new_items + new_i) T(std::move(*it));
     (*it).~T();
   }
-  allocator_.deallocate(items_, capacity_);
+  if (items_ != nullptr) allocator_.deallocate(items_, capacity_);
   items_ = new_items;
   capacity_ = new_capacity;
 }
 
 template<typename T, typename C, typename A>
 void req_compactor<T, C, A>::ensure_space(uint32_t num) {
+  reserve();

Review Comment:
   empty sketch case, we can avoid memory allocation. how about adding num == 0 
check in the L229?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to