Memory allocated with aligned_alloc() should be freed with free(), not
with delete - although in our actual implemention those are really the
same thing. gcc 11 warns about one such case, so instead of silencing
the warning, let's make it use free().

Signed-off-by: Nadav Har'El <n...@scylladb.com>
---
 core/trace.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/core/trace.cc b/core/trace.cc
index 4dd922ad..60fa18b9 100644
--- a/core/trace.cc
+++ b/core/trace.cc
@@ -61,16 +61,16 @@ constexpr size_t trace_page_size = 4096;  // need not match 
arch page size
 // Having a struct is more complex than it need be for just per-vcpu buffers,
 // _but_ it is in line with later on having rotating buffers, thus wwhy not do 
it already
 struct trace_buf {
-    std::unique_ptr<char[]>
+    std::unique_ptr<char[], decltype(&free)>
            _base;
     size_t _last;
     size_t _size;
 
     trace_buf() :
-            _base(nullptr), _last(0), _size(0) {
+            _base(nullptr, free), _last(0), _size(0) {
     }
     trace_buf(size_t size) :
-            _base(static_cast<char*>(aligned_alloc(sizeof(long), size))), 
_last(
+            _base(static_cast<char*>(aligned_alloc(sizeof(long), size)), 
free), _last(
                     0), _size(size) {
         static_assert(is_power_of_two(trace_page_size), "just checking");
         assert(is_power_of_two(size) && "size must be power of two");
-- 
2.31.1

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/20210614062057.1998552-9-nyh%40scylladb.com.

Reply via email to