mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-13 16:29:54 +02:00
Context: Renamed SetMemoryAllocators() to SetAllocatorFunctions(). Tweaked comments. (#1565, #586, #992, #1007, #1558)
This commit is contained in:
20
imgui.cpp
20
imgui.cpp
@ -213,7 +213,7 @@
|
||||
Here is a change-log of API breaking changes, if you are using one of the functions listed, expect to have to fix some code.
|
||||
Also read releases logs https://github.com/ocornut/imgui/releases for more details.
|
||||
|
||||
- 2018/01/20 (1.XX) - removed allocator parameters from CreateContext(), they are now setup with SetMemoryAllocators() and shared by all contexts.
|
||||
- 2018/01/20 (1.XX) - removed allocator parameters from CreateContext(), they are now setup with SetAllocatorFunctions() and shared by all contexts.
|
||||
- 2018/01/11 (1.54) - obsoleted IsAnyWindowHovered() in favor of IsWindowHovered(ImGuiHoveredFlags_AnyWindow). Kept redirection function (will obsolete).
|
||||
- 2018/01/11 (1.54) - obsoleted IsAnyWindowFocused() in favor of IsWindowFocused(ImGuiFocusedFlags_AnyWindow). Kept redirection function (will obsolete).
|
||||
- 2018/01/03 (1.54) - renamed ImGuiSizeConstraintCallback to ImGuiSizeCallback, ImGuiSizeConstraintCallbackData to ImGuiSizeCallbackData.
|
||||
@ -710,8 +710,8 @@ static ImGuiContext GImDefaultContext;
|
||||
ImGuiContext* GImGui = &GImDefaultContext;
|
||||
#endif
|
||||
|
||||
// Memory Allocator Functions. Use SetMemoryAllocators() to change them.
|
||||
// If you use DLL hotreloading you might need to call SetMemoryAllocators() after reloading code from this file.
|
||||
// Memory Allocator functions. Use SetAllocatorFunctions() to change them.
|
||||
// If you use DLL hotreloading you might need to call SetAllocatorFunctions() after reloading code from this file.
|
||||
// Otherwise, you probably don't want to modify them mid-program, and if you use global/static e.g. ImVector<> instances you may need to keep them accessible during program destruction.
|
||||
#ifndef IMGUI_DISABLE_DEFAULT_ALLOCATORS
|
||||
static void* MallocWrapper(size_t size, void* user_data) { (void)user_data; return malloc(size); }
|
||||
@ -724,7 +724,7 @@ static void FreeWrapper(void* ptr, void* user_data) { (void)user_data;
|
||||
static void* (*GImAllocatorAllocFunc)(size_t size, void* user_data) = MallocWrapper;
|
||||
static void (*GImAllocatorFreeFunc)(void* ptr, void* user_data) = FreeWrapper;
|
||||
static void* GImAllocatorUserData = NULL;
|
||||
static size_t GImAllocatorActiveCount = 0;
|
||||
static size_t GImAllocatorActiveAllocationsCount = 0;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// User facing structures
|
||||
@ -2188,13 +2188,13 @@ float ImGui::CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x)
|
||||
|
||||
void* ImGui::MemAlloc(size_t sz)
|
||||
{
|
||||
GImAllocatorActiveCount++;
|
||||
GImAllocatorActiveAllocationsCount++;
|
||||
return GImAllocatorAllocFunc(sz, GImAllocatorUserData);
|
||||
}
|
||||
|
||||
void ImGui::MemFree(void* ptr)
|
||||
{
|
||||
if (ptr) GImAllocatorActiveCount--;
|
||||
if (ptr) GImAllocatorActiveAllocationsCount--;
|
||||
return GImAllocatorFreeFunc(ptr, GImAllocatorUserData);
|
||||
}
|
||||
|
||||
@ -2230,10 +2230,10 @@ void ImGui::SetCurrentContext(ImGuiContext* ctx)
|
||||
#endif
|
||||
}
|
||||
|
||||
void ImGui::SetMemoryAllocators(void* (*alloc_fn)(size_t sz, void* user_data), void(*free_fn)(void* ptr, void* user_data), void* user_data)
|
||||
void ImGui::SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data), void(*free_func)(void* ptr, void* user_data), void* user_data)
|
||||
{
|
||||
GImAllocatorAllocFunc = alloc_fn;
|
||||
GImAllocatorFreeFunc = free_fn;
|
||||
GImAllocatorAllocFunc = alloc_func;
|
||||
GImAllocatorFreeFunc = free_func;
|
||||
GImAllocatorUserData = user_data;
|
||||
}
|
||||
|
||||
@ -11684,7 +11684,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
ImGui::Text("Dear ImGui %s", ImGui::GetVersion());
|
||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
||||
ImGui::Text("%d vertices, %d indices (%d triangles)", ImGui::GetIO().MetricsRenderVertices, ImGui::GetIO().MetricsRenderIndices, ImGui::GetIO().MetricsRenderIndices / 3);
|
||||
ImGui::Text("%d allocations", GImAllocatorActiveCount);
|
||||
ImGui::Text("%d allocations", GImAllocatorActiveAllocationsCount);
|
||||
static bool show_clip_rects = true;
|
||||
ImGui::Checkbox("Show clipping rectangles when hovering an ImDrawCmd", &show_clip_rects);
|
||||
ImGui::Separator();
|
||||
|
Reference in New Issue
Block a user