fix -Wclass-memaccess warnings (gcc 8.1)

pull/1822/head
Francisco Demartino
parent 20d8be7dd1
commit 9238098ac1

@ -1236,7 +1236,7 @@ public:
value_type* new_data = (value_type*)ImGui::MemAlloc((size_t)new_capacity * sizeof(value_type));
if (Data)
{
memcpy(new_data, Data, (size_t)Size * sizeof(value_type));
for (int n = 0; n < Size; n++) new_data[n] = Data[n];
ImGui::MemFree(Data);
}
Data = new_data;
@ -1244,7 +1244,7 @@ public:
}
// NB: &v cannot be pointing inside the ImVector Data itself! e.g. v.push_back(v[10]) is forbidden.
inline void push_back(const value_type& v) { if (Size == Capacity) reserve(_grow_capacity(Size + 1)); memcpy(&Data[Size], &v, sizeof(v)); Size++; }
inline void push_back(const value_type& v) { if (Size == Capacity) reserve(_grow_capacity(Size + 1)); Data[Size] = v; Size++; }
inline void pop_back() { IM_ASSERT(Size > 0); Size--; }
inline void push_front(const value_type& v) { if (Size == 0) push_back(v); else insert(Data, v); }
inline iterator erase(const_iterator it) { IM_ASSERT(it >= Data && it < Data+Size); const ptrdiff_t off = it - Data; memmove(Data + off, Data + off + 1, ((size_t)Size - (size_t)off - 1) * sizeof(value_type)); Size--; return Data + off; }

@ -351,7 +351,7 @@ void ImDrawList::ClearFreeMemory()
_ChannelsCount = 1;
for (int i = 0; i < _Channels.Size; i++)
{
if (i == 0) memset(&_Channels[0], 0, sizeof(_Channels[0])); // channel 0 is a copy of CmdBuffer/IdxBuffer, don't destruct again
if (i == 0) _Channels[0] = ImDrawChannel(); // channel 0 is a copy of CmdBuffer/IdxBuffer, don't destruct again
_Channels[i].CmdBuffer.clear();
_Channels[i].IdxBuffer.clear();
}
@ -494,7 +494,7 @@ void ImDrawList::ChannelsSplit(int channels_count)
// _Channels[] (24/32 bytes each) hold storage that we'll swap with this->_CmdBuffer/_IdxBuffer
// The content of _Channels[0] at this point doesn't matter. We clear it to make state tidy in a debugger but we don't strictly need to.
// When we switch to the next channel, we'll copy _CmdBuffer/_IdxBuffer into _Channels[0] and then _Channels[1] into _CmdBuffer/_IdxBuffer
memset(&_Channels[0], 0, sizeof(ImDrawChannel));
_Channels[0] = ImDrawChannel();
for (int i = 1; i < channels_count; i++)
{
if (i >= old_channels_count)
@ -554,11 +554,11 @@ void ImDrawList::ChannelsSetCurrent(int idx)
{
IM_ASSERT(idx < _ChannelsCount);
if (_ChannelsCurrent == idx) return;
memcpy(&_Channels.Data[_ChannelsCurrent].CmdBuffer, &CmdBuffer, sizeof(CmdBuffer)); // copy 12 bytes, four times
memcpy(&_Channels.Data[_ChannelsCurrent].IdxBuffer, &IdxBuffer, sizeof(IdxBuffer));
_Channels.Data[_ChannelsCurrent].CmdBuffer = CmdBuffer; // copy 12 bytes, four times
_Channels.Data[_ChannelsCurrent].IdxBuffer = IdxBuffer;
_ChannelsCurrent = idx;
memcpy(&CmdBuffer, &_Channels.Data[_ChannelsCurrent].CmdBuffer, sizeof(CmdBuffer));
memcpy(&IdxBuffer, &_Channels.Data[_ChannelsCurrent].IdxBuffer, sizeof(IdxBuffer));
CmdBuffer = _Channels.Data[_ChannelsCurrent].CmdBuffer;
IdxBuffer = _Channels.Data[_ChannelsCurrent].IdxBuffer;
_IdxWritePtr = IdxBuffer.Data + IdxBuffer.Size;
}

Loading…
Cancel
Save