summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-06-29 14:47:30 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-06-29 14:47:30 +0000
commita2df3ffb81c130be99896a9c22c93f05394cb13a (patch)
treea124b16e8b438aca8d1521dc1af1ea29b9e0c6d4 /vespalib
parent8bd14af6425ee6bc70a76162eac3893912e6476f (diff)
Make address sanitizer happy
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/util/alloc.h4
-rw-r--r--vespalib/src/vespa/vespalib/util/memory_allocator.h1
2 files changed, 3 insertions, 2 deletions
diff --git a/vespalib/src/vespa/vespalib/util/alloc.h b/vespalib/src/vespa/vespalib/util/alloc.h
index 794d3fd6f6e..a27bcca0b47 100644
--- a/vespalib/src/vespa/vespalib/util/alloc.h
+++ b/vespalib/src/vespa/vespalib/util/alloc.h
@@ -60,7 +60,7 @@ public:
void reset() noexcept {
if (_alloc.get() != nullptr) {
_allocator->free(_alloc);
- _alloc = PtrAndSize();
+ _alloc.reset();
}
}
Alloc create(size_t sz) const noexcept {
@@ -90,7 +90,7 @@ private:
_allocator(allocator)
{ }
void clear() noexcept {
- _alloc = PtrAndSize();
+ _alloc.reset();
_allocator = nullptr;
}
PtrAndSize _alloc;
diff --git a/vespalib/src/vespa/vespalib/util/memory_allocator.h b/vespalib/src/vespa/vespalib/util/memory_allocator.h
index 0bc66926b04..1aa3360943f 100644
--- a/vespalib/src/vespa/vespalib/util/memory_allocator.h
+++ b/vespalib/src/vespa/vespalib/util/memory_allocator.h
@@ -14,6 +14,7 @@ public:
PtrAndSize(void * ptr, size_t sz) noexcept;
void * get() const noexcept { return _ptr; }
size_t size() const noexcept { return _sz; }
+ void reset() noexcept { _ptr = nullptr; _sz = 0ul; }
private:
void * _ptr;
size_t _sz;