mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-23 21:09:01 +08:00
Demo: use ImGui::MemAlloc/MemFree for consistency. (#7300)
This commit is contained in:
parent
76e09c4b0f
commit
5cdc4a2a41
@ -6997,19 +6997,19 @@ struct ExampleAppConsole
|
||||
{
|
||||
ClearLog();
|
||||
for (int i = 0; i < History.Size; i++)
|
||||
free(History[i]);
|
||||
ImGui::MemFree(History[i]);
|
||||
}
|
||||
|
||||
// Portable helpers
|
||||
static int Stricmp(const char* s1, const char* s2) { int d; while ((d = toupper(*s2) - toupper(*s1)) == 0 && *s1) { s1++; s2++; } return d; }
|
||||
static int Strnicmp(const char* s1, const char* s2, int n) { int d = 0; while (n > 0 && (d = toupper(*s2) - toupper(*s1)) == 0 && *s1) { s1++; s2++; n--; } return d; }
|
||||
static char* Strdup(const char* s) { IM_ASSERT(s); size_t len = strlen(s) + 1; void* buf = malloc(len); IM_ASSERT(buf); return (char*)memcpy(buf, (const void*)s, len); }
|
||||
static char* Strdup(const char* s) { IM_ASSERT(s); size_t len = strlen(s) + 1; void* buf = ImGui::MemAlloc(len); IM_ASSERT(buf); return (char*)memcpy(buf, (const void*)s, len); }
|
||||
static void Strtrim(char* s) { char* str_end = s + strlen(s); while (str_end > s && str_end[-1] == ' ') str_end--; *str_end = 0; }
|
||||
|
||||
void ClearLog()
|
||||
{
|
||||
for (int i = 0; i < Items.Size; i++)
|
||||
free(Items[i]);
|
||||
ImGui::MemFree(Items[i]);
|
||||
Items.clear();
|
||||
}
|
||||
|
||||
@ -7175,7 +7175,7 @@ struct ExampleAppConsole
|
||||
for (int i = History.Size - 1; i >= 0; i--)
|
||||
if (Stricmp(History[i], command_line) == 0)
|
||||
{
|
||||
free(History[i]);
|
||||
ImGui::MemFree(History[i]);
|
||||
History.erase(History.begin() + i);
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user