diff --git a/Source/Project64/UserInterface/Debugger/Debugger-MemorySearch.cpp b/Source/Project64/UserInterface/Debugger/Debugger-MemorySearch.cpp index 3f0c520fa..90c35823d 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-MemorySearch.cpp +++ b/Source/Project64/UserInterface/Debugger/Debugger-MemorySearch.cpp @@ -1652,7 +1652,7 @@ void CDebugMemorySearch::Search(void) } } - m_MemoryScanner.SetValue(value._string); + m_MemoryScanner.SetValue(value._string); m_MemoryScanner.SetStringValueLength(stringValueLength); break; case ValueType_unkstring: @@ -1662,7 +1662,7 @@ void CDebugMemorySearch::Search(void) goto value_parse_error; } - m_MemoryScanner.SetValue(value._string); + m_MemoryScanner.SetValue(value._string); m_MemoryScanner.SetStringValueLength(stringValueLength); break; default: @@ -2313,7 +2313,7 @@ CEditMixed::~CEditMixed(void) { if (m_String != NULL) { - free(m_String); + delete[] m_String; } } @@ -2331,11 +2331,11 @@ void CEditMixed::ReloadString(void) { if (m_String != NULL) { - free(m_String); + delete[] m_String; } m_StringLength = GetWindowTextLength(); - m_String = (wchar_t*) malloc(m_StringLength + 1); + m_String = new wchar_t[m_StringLength + 1]; GetWindowText(m_String, m_StringLength + 1); } @@ -2526,7 +2526,7 @@ bool CEditMixed::GetValue(double& value) return true; } -bool CEditMixed::GetValueString(const char*& value, int& length) +bool CEditMixed::GetValueString(const wchar_t*& value, int& length) { ReloadString(); @@ -2535,12 +2535,12 @@ bool CEditMixed::GetValueString(const char*& value, int& length) return false; } - value = (const char*)m_String; + value = m_String; length = m_StringLength; return true; } -bool CEditMixed::GetValueHexString(const char*& value, int& length) +bool CEditMixed::GetValueHexString(const wchar_t*& value, int& length) { ReloadString(); @@ -2558,18 +2558,19 @@ bool CEditMixed::GetValueHexString(const char*& value, int& length) } - char *hexString = (char*)malloc(numBytes); + char *hexString = new char[numBytes]; + wchar_t *wchexString = new wchar_t[numBytes]; + CMemoryScanner::ParseHexString(hexString, string.c_str()); - wchar_t *wchexString = (wchar_t*)malloc(numBytes * sizeof(wchar_t)); wcscpy(wchexString, stdstr(hexString).ToUTF16().c_str()); - free(hexString); - free(m_String); + delete[] hexString; + delete[] m_String; m_String = wchexString; m_StringLength = numBytes; - value = (const char*)m_String; + value = m_String; length = m_StringLength; return true; } diff --git a/Source/Project64/UserInterface/Debugger/Debugger-MemorySearch.h b/Source/Project64/UserInterface/Debugger/Debugger-MemorySearch.h index 9a34e6073..3d3592faf 100644 --- a/Source/Project64/UserInterface/Debugger/Debugger-MemorySearch.h +++ b/Source/Project64/UserInterface/Debugger/Debugger-MemorySearch.h @@ -45,8 +45,8 @@ public: bool GetValue(int64_t& value); bool GetValue(float& value); bool GetValue(double& value); - bool GetValueString(const char*& value, int& length); - bool GetValueHexString(const char*& value, int& length); + bool GetValueString(const wchar_t*& value, int& length); + bool GetValueHexString(const wchar_t*& value, int& length); BEGIN_MSG_MAP_EX(CEditMixed) //MSG_WM_CHAR(OnChar) diff --git a/Source/Project64/UserInterface/Debugger/MemoryScanner.cpp b/Source/Project64/UserInterface/Debugger/MemoryScanner.cpp index 5ffb74544..824c4a441 100644 --- a/Source/Project64/UserInterface/Debugger/MemoryScanner.cpp +++ b/Source/Project64/UserInterface/Debugger/MemoryScanner.cpp @@ -744,7 +744,7 @@ void CMemoryScanner::FirstScanLoopString(DisplayFormat resultDisplayFormat) } result.m_Address = addr | m_VAddrBits; - result.Set((const char*)NULL); + result.Set((const wchar_t*)NULL); m_Results.push_back(result); next_addr:; } @@ -773,7 +773,7 @@ void CMemoryScanner::FirstScanLoopIString(DisplayFormat resultDisplayFormat) } result.m_Address = addr | m_VAddrBits; - result.Set((const char*)NULL); + result.Set((const wchar_t*)NULL); m_Results.push_back(result); next_addr:; } @@ -782,7 +782,7 @@ void CMemoryScanner::FirstScanLoopIString(DisplayFormat resultDisplayFormat) // scan for text of unknown single-byte encoding void CMemoryScanner::FirstScanLoopUnkString(void) { - const uint8_t* str = (const uint8_t*)m_Value._string; + const char* str = stdstr().FromUTF16(m_Value._string).c_str(); int length = m_StringValueLength; uint32_t startAddr = m_RangeStartAddress; @@ -846,7 +846,7 @@ void CMemoryScanner::FirstScanLoopUnkString(void) } result.m_Address = addr | m_VAddrBits; - result.Set((const char*)NULL); + result.Set((const wchar_t*)NULL); m_Results.push_back(result); next_addr:; diff --git a/Source/Project64/UserInterface/Debugger/MemoryScanner.h b/Source/Project64/UserInterface/Debugger/MemoryScanner.h index 4030bac14..bc6644f33 100644 --- a/Source/Project64/UserInterface/Debugger/MemoryScanner.h +++ b/Source/Project64/UserInterface/Debugger/MemoryScanner.h @@ -71,7 +71,7 @@ typedef union { int64_t _sint64; float _float; double _double; - const char* _string; + const wchar_t* _string; } MixedValue; class CMixed @@ -106,7 +106,7 @@ public: inline void Set(int64_t v) { SetType(ValueType_int64); m_Value._sint64 = v; } inline void Set(float v) { SetType(ValueType_float); m_Value._float = v; } inline void Set(double v) { SetType(ValueType_double); m_Value._double = v; } - inline void Set(const char* v) { SetType(ValueType_string); m_Value._string = v; } + inline void Set(const wchar_t* v) { SetType(ValueType_string); m_Value._string = v; } inline void Get(uint8_t* v) { *v = m_Value._uint8; } inline void Get(int8_t* v) { *v = m_Value._sint8; } @@ -118,7 +118,7 @@ public: inline void Get(int64_t* v) { *v = m_Value._sint64; } inline void Get(float* v) { *v = m_Value._float; } inline void Get(double* v) { *v = m_Value._double; } - inline void Get(const char** v) { *v = m_Value._string; } + inline void Get(const wchar_t** v) { *v = m_Value._string; } const char* GetTypeName(void); int GetTypeSize(void);