Cleanup CVT functions

This commit is contained in:
2025-07-20 15:13:13 +10:00
parent 804e5ed0a8
commit dbc3fe63f8
9 changed files with 202 additions and 190 deletions
+5 -5
View File
@@ -229,8 +229,8 @@ DN_API void DN_Debug_TrackAlloc(void *ptr, DN_USize size, bool leak_permitted)
DN_DebugAlloc *alloc = alloc_entry.value;
if (alloc_entry.found) {
if ((alloc->flags & DN_DebugAllocFlag_Freed) == 0) {
DN_Str8 alloc_size = DN_CVT_U64ToByteSizeStr8(alloc_table->arena, alloc->size, DN_CVTU64ByteSizeType_Auto);
DN_Str8 new_alloc_size = DN_CVT_U64ToByteSizeStr8(alloc_table->arena, size, DN_CVTU64ByteSizeType_Auto);
DN_Str8 alloc_size = DN_CVT_U64ToBytesStr8Auto(alloc_table->arena, alloc->size);
DN_Str8 new_alloc_size = DN_CVT_U64ToBytesStr8Auto(alloc_table->arena, size);
DN_HardAssertF(
alloc->flags & DN_DebugAllocFlag_Freed,
"This pointer is already in the leak tracker, however it has not been freed yet. This "
@@ -287,7 +287,7 @@ DN_API void DN_Debug_TrackDealloc(void *ptr)
DN_DebugAlloc *alloc = alloc_entry.value;
if (alloc->flags & DN_DebugAllocFlag_Freed) {
DN_Str8 freed_size = DN_CVT_U64ToByteSizeStr8(alloc_table->arena, alloc->freed_size, DN_CVTU64ByteSizeType_Auto);
DN_Str8 freed_size = DN_CVT_U64ToBytesStr8Auto(alloc_table->arena, alloc->freed_size);
DN_HardAssertF((alloc->flags & DN_DebugAllocFlag_Freed) == 0,
"Double free detected, pointer to free was already marked "
"as freed. Either the pointer was reallocated but not "
@@ -329,7 +329,7 @@ DN_API void DN_Debug_DumpLeaks()
if (alloc_leaked && !leak_permitted) {
leaked_bytes += alloc->size;
leak_count++;
DN_Str8 alloc_size = DN_CVT_U64ToByteSizeStr8(g_dn_core->alloc_table.arena, alloc->size, DN_CVTU64ByteSizeType_Auto);
DN_Str8 alloc_size = DN_CVT_U64ToBytesStr8Auto(g_dn_core->alloc_table.arena, alloc->size);
DN_LOG_WarningF("Pointer (0x%p) leaked %.*s at:\n"
"%.*s",
alloc->ptr, DN_STR_FMT(alloc_size),
@@ -340,7 +340,7 @@ DN_API void DN_Debug_DumpLeaks()
if (leak_count) {
char buffer[512];
DN_Arena arena = DN_Arena_InitFromBuffer(buffer, sizeof(buffer), DN_ArenaFlags_Nil);
DN_Str8 leak_size = DN_CVT_U64ToByteSizeStr8(&arena, leaked_bytes, DN_CVTU64ByteSizeType_Auto);
DN_Str8 leak_size = DN_CVT_U64ToBytesStr8Auto(&arena, leaked_bytes);
DN_LOG_WarningF("There were %I64u leaked allocations totalling %.*s", leak_count, DN_STR_FMT(leak_size));
}
}