diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-06-29 14:47:30 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2023-06-29 14:47:30 +0000 |
commit | a2df3ffb81c130be99896a9c22c93f05394cb13a (patch) | |
tree | a124b16e8b438aca8d1521dc1af1ea29b9e0c6d4 /vespalib | |
parent | 8bd14af6425ee6bc70a76162eac3893912e6476f (diff) |
Make address sanitizer happy
Diffstat (limited to 'vespalib')
-rw-r--r-- | vespalib/src/vespa/vespalib/util/alloc.h | 4 | ||||
-rw-r--r-- | vespalib/src/vespa/vespalib/util/memory_allocator.h | 1 |
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; |