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);