Added temp arena and use it in hot reload

This commit is contained in:
2026-02-15 13:33:27 -05:00
parent 38f8662d80
commit 4ca3ef1706
4 changed files with 24 additions and 4 deletions

2
External/Imgui vendored

View File

@@ -51,6 +51,12 @@ namespace Juliet
};
static_assert(sizeof(Arena) <= k_ArenaHeaderSize);
struct TempArena
{
Arena* Arena;
index_t Position;
};
struct ArenaParams
{
uint64 ReserveSize = g_Arena_Default_Reserve_Size;
@@ -97,4 +103,7 @@ namespace Juliet
return static_cast<Type*>(ArenaPush(arena, sizeof(Type) * count, Max(8ull, AlignOf(Type)),
true JULIET_DEBUG_ONLY(, typeid(Type).name())));
}
TempArena ArenaTempBegin(NonNullPtr<Arena> arena);
void ArenaTempEnd(TempArena temp);
} // namespace Juliet

View File

@@ -56,8 +56,8 @@ namespace Juliet
basePathLength + StringLength(code.TransientDLLName) + /* _ */ 1 + kTempDLLBufferSizeForID + 1 /* \0 */;
// Allocate from Scratch Arena (transient)
index_t pos = ArenaPos(code.Arena);
auto tempDllPath = ArenaPushArray<char>(code.Arena, tempDllMaxBufferSize);
TempArena temp = ArenaTempBegin(code.Arena);
auto tempDllPath = ArenaPushArray<char>(temp.Arena, tempDllMaxBufferSize);
for (uint32 attempt = 0; attempt < kMaxAttempts; ++attempt)
{
@@ -97,7 +97,7 @@ namespace Juliet
break;
}
}
ArenaPopTo(code.Arena, pos);
ArenaTempEnd(temp);
code.Dll = LoadDynamicLibrary(tempDllPath);
if (code.Dll)

View File

@@ -327,4 +327,15 @@ namespace Juliet
size_t position = current->BasePosition + current->Position;
return position;
}
TempArena ArenaTempBegin(NonNullPtr<Arena> arena)
{
index_t position = ArenaPos(arena);
return { arena.Get(), position };
}
void ArenaTempEnd(TempArena temp)
{
ArenaPopTo(temp.Arena, temp.Position);
}
} // namespace Juliet