mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-07 05:28:47 +02:00
ImVector: reserve() tweak to avoid undefined behavior warning (#731)
This commit is contained in:
3
imgui.h
3
imgui.h
@ -885,7 +885,8 @@ public:
|
|||||||
{
|
{
|
||||||
if (new_capacity <= Capacity) return;
|
if (new_capacity <= Capacity) return;
|
||||||
T* new_data = (value_type*)ImGui::MemAlloc((size_t)new_capacity * sizeof(value_type));
|
T* new_data = (value_type*)ImGui::MemAlloc((size_t)new_capacity * sizeof(value_type));
|
||||||
memcpy(new_data, Data, (size_t)Size * sizeof(value_type));
|
if (Data)
|
||||||
|
memcpy(new_data, Data, (size_t)Size * sizeof(value_type));
|
||||||
ImGui::MemFree(Data);
|
ImGui::MemFree(Data);
|
||||||
Data = new_data;
|
Data = new_data;
|
||||||
Capacity = new_capacity;
|
Capacity = new_capacity;
|
||||||
|
Reference in New Issue
Block a user