mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 12:08:47 +02:00
Merge branch 'vulkan_fix_master' into vulkan_fix_docking
This commit is contained in:
20
imgui.cpp
20
imgui.cpp
@ -1344,7 +1344,7 @@ void ImStrncpy(char* dst, const char* src, size_t count)
|
||||
char* ImStrdup(const char* str)
|
||||
{
|
||||
size_t len = strlen(str);
|
||||
void* buf = ImGui::MemAlloc(len + 1);
|
||||
void* buf = IM_ALLOC(len + 1);
|
||||
return (char*)memcpy(buf, (const void*)str, len + 1);
|
||||
}
|
||||
|
||||
@ -1354,8 +1354,8 @@ char* ImStrdupcpy(char* dst, size_t* p_dst_size, const char* src)
|
||||
size_t src_size = strlen(src) + 1;
|
||||
if (dst_buf_size < src_size)
|
||||
{
|
||||
ImGui::MemFree(dst);
|
||||
dst = (char*)ImGui::MemAlloc(src_size);
|
||||
IM_FREE(dst);
|
||||
dst = (char*)IM_ALLOC(src_size);
|
||||
if (p_dst_size)
|
||||
*p_dst_size = src_size;
|
||||
}
|
||||
@ -1571,7 +1571,7 @@ FILE* ImFileOpen(const char* filename, const char* mode)
|
||||
}
|
||||
|
||||
// Load file content into memory
|
||||
// Memory allocated with ImGui::MemAlloc(), must be freed by user using ImGui::MemFree()
|
||||
// Memory allocated with IM_ALLOC(), must be freed by user using IM_FREE() == ImGui::MemFree()
|
||||
void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, size_t* out_file_size, int padding_bytes)
|
||||
{
|
||||
IM_ASSERT(filename && file_open_mode);
|
||||
@ -1590,7 +1590,7 @@ void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, size_
|
||||
}
|
||||
|
||||
size_t file_size = (size_t)file_size_signed;
|
||||
void* file_data = ImGui::MemAlloc(file_size + padding_bytes);
|
||||
void* file_data = IM_ALLOC(file_size + padding_bytes);
|
||||
if (file_data == NULL)
|
||||
{
|
||||
fclose(f);
|
||||
@ -1599,7 +1599,7 @@ void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, size_
|
||||
if (fread(file_data, 1, file_size, f) != file_size)
|
||||
{
|
||||
fclose(f);
|
||||
ImGui::MemFree(file_data);
|
||||
IM_FREE(file_data);
|
||||
return NULL;
|
||||
}
|
||||
if (padding_bytes > 0)
|
||||
@ -3024,6 +3024,7 @@ float ImGui::CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x)
|
||||
return ImMax(wrap_pos_x - pos.x, 1.0f);
|
||||
}
|
||||
|
||||
// IM_ALLOC() == ImGui::MemAlloc()
|
||||
void* ImGui::MemAlloc(size_t size)
|
||||
{
|
||||
if (ImGuiContext* ctx = GImGui)
|
||||
@ -3031,6 +3032,7 @@ void* ImGui::MemAlloc(size_t size)
|
||||
return GImAllocatorAllocFunc(size, GImAllocatorUserData);
|
||||
}
|
||||
|
||||
// IM_FREE() == ImGui::MemFree()
|
||||
void ImGui::MemFree(void* ptr)
|
||||
{
|
||||
if (ptr)
|
||||
@ -9791,7 +9793,7 @@ void ImGui::LoadIniSettingsFromDisk(const char* ini_filename)
|
||||
if (!file_data)
|
||||
return;
|
||||
LoadIniSettingsFromMemory(file_data, (size_t)file_data_size);
|
||||
ImGui::MemFree(file_data);
|
||||
IM_FREE(file_data);
|
||||
}
|
||||
|
||||
ImGuiSettingsHandler* ImGui::FindSettingsHandler(const char* type_name)
|
||||
@ -9815,7 +9817,7 @@ void ImGui::LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size)
|
||||
// For our convenience and to make the code simpler, we'll also write zero-terminators within the buffer. So let's create a writable copy..
|
||||
if (ini_size == 0)
|
||||
ini_size = strlen(ini_data);
|
||||
char* buf = (char*)ImGui::MemAlloc(ini_size + 1);
|
||||
char* buf = (char*)IM_ALLOC(ini_size + 1);
|
||||
char* buf_end = buf + ini_size;
|
||||
memcpy(buf, ini_data, ini_size);
|
||||
buf[ini_size] = 0;
|
||||
@ -9862,7 +9864,7 @@ void ImGui::LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size)
|
||||
entry_handler->ReadLineFn(&g, entry_handler, entry_data, line);
|
||||
}
|
||||
}
|
||||
ImGui::MemFree(buf);
|
||||
IM_FREE(buf);
|
||||
g.SettingsLoaded = true;
|
||||
DockContextOnLoadSettings(&g);
|
||||
}
|
||||
|
Reference in New Issue
Block a user