Added missing construction and destruction of StackAllocatorSnapshotData, which is only required when MIJIN_STACK_ALLOCATOR_DEBUG is 2.

This commit is contained in:
Patrick 2025-07-02 16:40:46 +02:00
parent 6090d5fc74
commit bf53622b19

View File

@ -326,6 +326,7 @@ public:
// couldn't allocate the snapshot // couldn't allocate the snapshot
return {}; return {};
} }
::new (snapshotData) StackAllocatorSnapshotData;
StackAllocatorSnapshot snapshot; StackAllocatorSnapshot snapshot;
snapshot.data = snapshotData; snapshot.data = snapshotData;
if (firstChunk_ != prevFirst) if (firstChunk_ != prevFirst)
@ -442,6 +443,7 @@ public:
Chunk* snapshotChunk = findChunk(snapshot.data); Chunk* snapshotChunk = findChunk(snapshot.data);
MIJIN_ASSERT_FATAL(snapshotChunk != nullptr, "Snapshot not in chunks?"); MIJIN_ASSERT_FATAL(snapshotChunk != nullptr, "Snapshot not in chunks?");
snapshotChunk->allocated -= calcSnapshotSize(snapshot->numChunks); // note: this might miss the alignment bytes of the snapshot, but that should be fine snapshotChunk->allocated -= calcSnapshotSize(snapshot->numChunks); // note: this might miss the alignment bytes of the snapshot, but that should be fine
snapshot.data->~StackAllocatorSnapshotData();
} }
private: private:
void initAndAddChunk(Chunk* newChunk) noexcept void initAndAddChunk(Chunk* newChunk) noexcept