mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-01-21 20:30:41 +00:00
events: use SDL_memmove instead of SDL_memcpy for overlapping memory
This commit is contained in:
@@ -160,7 +160,7 @@ void SDL_RemoveKeyboard(SDL_KeyboardID keyboardID, bool send_event)
|
||||
SDL_free(SDL_keyboards[keyboard_index].name);
|
||||
|
||||
if (keyboard_index != SDL_keyboard_count - 1) {
|
||||
SDL_memcpy(&SDL_keyboards[keyboard_index], &SDL_keyboards[keyboard_index + 1], (SDL_keyboard_count - keyboard_index - 1) * sizeof(SDL_keyboards[keyboard_index]));
|
||||
SDL_memmove(&SDL_keyboards[keyboard_index], &SDL_keyboards[keyboard_index + 1], (SDL_keyboard_count - keyboard_index - 1) * sizeof(SDL_keyboards[keyboard_index]));
|
||||
}
|
||||
--SDL_keyboard_count;
|
||||
|
||||
|
||||
@@ -328,7 +328,7 @@ void SDL_RemoveMouse(SDL_MouseID mouseID, bool send_event)
|
||||
SDL_free(SDL_mice[mouse_index].name);
|
||||
|
||||
if (mouse_index != SDL_mouse_count - 1) {
|
||||
SDL_memcpy(&SDL_mice[mouse_index], &SDL_mice[mouse_index + 1], (SDL_mouse_count - mouse_index - 1) * sizeof(SDL_mice[mouse_index]));
|
||||
SDL_memmove(&SDL_mice[mouse_index], &SDL_mice[mouse_index + 1], (SDL_mouse_count - mouse_index - 1) * sizeof(SDL_mice[mouse_index]));
|
||||
}
|
||||
--SDL_mouse_count;
|
||||
|
||||
@@ -339,7 +339,7 @@ void SDL_RemoveMouse(SDL_MouseID mouseID, bool send_event)
|
||||
if (source->mouseID == mouseID) {
|
||||
SDL_free(source->clickstate);
|
||||
if (i != mouse->num_sources - 1) {
|
||||
SDL_memcpy(&mouse->sources[i], &mouse->sources[i + 1], (mouse->num_sources - i - 1) * sizeof(mouse->sources[i]));
|
||||
SDL_memmove(&mouse->sources[i], &mouse->sources[i + 1], (mouse->num_sources - i - 1) * sizeof(mouse->sources[i]));
|
||||
}
|
||||
--mouse->num_sources;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user