mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-25 08:10:30 +01:00
Examples: Console: example uses standard malloc/free, makes more sense as a copy & pastable example
This commit is contained in:
parent
d9ca8f3145
commit
222a9231bb
10
imgui.cpp
10
imgui.cpp
@ -11242,13 +11242,13 @@ struct ExampleAppConsole
|
|||||||
{
|
{
|
||||||
ClearLog();
|
ClearLog();
|
||||||
for (size_t i = 0; i < Items.size(); i++)
|
for (size_t i = 0; i < Items.size(); i++)
|
||||||
ImGui::MemFree(History[i]);
|
free(History[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearLog()
|
void ClearLog()
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < Items.size(); i++)
|
for (size_t i = 0; i < Items.size(); i++)
|
||||||
ImGui::MemFree(Items[i]);
|
free(Items[i]);
|
||||||
Items.clear();
|
Items.clear();
|
||||||
ScrollToBottom = true;
|
ScrollToBottom = true;
|
||||||
}
|
}
|
||||||
@ -11260,7 +11260,7 @@ struct ExampleAppConsole
|
|||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
ImFormatStringV(buf, IM_ARRAYSIZE(buf), fmt, args);
|
ImFormatStringV(buf, IM_ARRAYSIZE(buf), fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
Items.push_back(ImStrdup(buf));
|
Items.push_back(strdup(buf));
|
||||||
ScrollToBottom = true;
|
ScrollToBottom = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -11343,11 +11343,11 @@ struct ExampleAppConsole
|
|||||||
for (int i = (int)History.size()-1; i >= 0; i--)
|
for (int i = (int)History.size()-1; i >= 0; i--)
|
||||||
if (ImStricmp(History[i], command_line) == 0)
|
if (ImStricmp(History[i], command_line) == 0)
|
||||||
{
|
{
|
||||||
ImGui::MemFree(History[i]);
|
free(History[i]);
|
||||||
History.erase(History.begin() + i);
|
History.erase(History.begin() + i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
History.push_back(ImStrdup(command_line));
|
History.push_back(strdup(command_line));
|
||||||
|
|
||||||
// Process command
|
// Process command
|
||||||
if (ImStricmp(command_line, "CLEAR") == 0)
|
if (ImStricmp(command_line, "CLEAR") == 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user