From 26c66bcefba927e439eecb49a4de648e327de7ac Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Wed, 1 May 2024 17:24:48 -0700 Subject: [PATCH] Return `this` from addref for Entry --- VersionedMap.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/VersionedMap.cpp b/VersionedMap.cpp index f28c220..8a558e5 100644 --- a/VersionedMap.cpp +++ b/VersionedMap.cpp @@ -76,7 +76,10 @@ struct Entry { return (const uint8_t *)(this + 1) + 1 + keyLen; } - void addref() const { ++refCount; } + Entry *addref() const { + ++refCount; + return (Entry *)this; + } void delref() const { if (--refCount == 0) { @@ -420,8 +423,7 @@ struct VersionedMap::Impl { auto doCopy = [&]() { uint32_t copy = mm.allocate(); auto &c = mm.base[copy]; - n.entry->addref(); - c.entry = n.entry; + c.entry = n.entry->addref(); c.pointer[which] = child; c.pointer[!which] = n.pointer[!which]; c.updated.store(false, std::memory_order_relaxed);