diff --git a/src/prim/windows/windbg/mimalloc_windbg_process_info.cpp b/src/prim/windows/windbg/mimalloc_windbg_process_info.cpp index 5dd7e977..bea82832 100644 --- a/src/prim/windows/windbg/mimalloc_windbg_process_info.cpp +++ b/src/prim/windows/windbg/mimalloc_windbg_process_info.cpp @@ -83,7 +83,7 @@ extern "C" __declspec(dllexport) HRESULT CALLBACK mi_dump_process_info(PDEBUG_CL // Convert wide string to narrow string std::string commandLine; commandLine.resize(cmdLine.Length / sizeof(WCHAR) + 1); // +1 for null terminator - WideCharToMultiByte(CP_UTF8, 0, commandLineWide.c_str(), -1, commandLine.data(), commandLine.size(), nullptr, nullptr); + WideCharToMultiByte(CP_UTF8, 0, commandLineWide.c_str(), -1, commandLine.data(), static_cast(commandLine.size()), nullptr, nullptr); // Get Processor Type (x86, x64, ARM64, etc.) ULONG processorType = 0; diff --git a/src/prim/windows/windbg/mimalloc_windbg_utils.cpp b/src/prim/windows/windbg/mimalloc_windbg_utils.cpp index 86c40479..22a894e2 100644 --- a/src/prim/windows/windbg/mimalloc_windbg_utils.cpp +++ b/src/prim/windows/windbg/mimalloc_windbg_utils.cpp @@ -187,12 +187,12 @@ size_t mi_bitmap_count(mi_bitmap_t* bmp) { return totalCount; } -std::string FormatSize(std::size_t bytes) { +std::string FormatSize(int64_t value) { const char* suffixes[] = {"B", "KiB", "MiB", "GiB", "TiB", "PiB"}; constexpr int maxIndex = static_cast(std::size(suffixes)) - 1; - double size = static_cast(bytes); int index = 0; + double size = static_cast(value); while (size >= 1024.0 && index < maxIndex) { size /= 1024.0; ++index; @@ -201,11 +201,12 @@ std::string FormatSize(std::size_t bytes) { return std::format("{:.2f} {}", size, suffixes[index]); } -std::string FormatNumber(double num) { +std::string FormatNumber(int64_t value) { const char* suffixes[] = {"", "K", "M", "B", "T"}; constexpr int maxIndex = static_cast(std::size(suffixes)) - 1; int index = 0; + double num = static_cast(value); while (num >= 1000.0 && index < maxIndex) { num /= 1000.0; ++index; diff --git a/src/prim/windows/windbg/mimalloc_windbg_utils.h b/src/prim/windows/windbg/mimalloc_windbg_utils.h index e3f74a22..15c5dd3a 100644 --- a/src/prim/windows/windbg/mimalloc_windbg_utils.h +++ b/src/prim/windows/windbg/mimalloc_windbg_utils.h @@ -37,8 +37,8 @@ HRESULT ReadMemory(ULONG64 address, void* outBuffer, ULONG bufferSize); HRESULT ReadString(const char* symbolName, std::string& outBuffer); HRESULT ReadWideString(ULONG64 address, std::wstring& outString, size_t maxLength = 1024); size_t mi_bitmap_count(mi_bitmap_t* bmp); -std::string FormatSize(std::size_t bytes); -std::string FormatNumber(double num); +std::string FormatSize(int64_t bytes); +std::string FormatNumber(int64_t num); inline void PrintLink(ULONG64 addr, std::string cmd, std::string linkText, std::string extraText = "") { g_DebugControl->ControlledOutput(DEBUG_OUTCTL_AMBIENT_DML, DEBUG_OUTPUT_NORMAL,