Skip to content

Commit 191a641

Browse files
Green-Skyslouken
authored andcommitted
events: use SDL_memmove instead of SDL_memcpy for overlapping memory
1 parent bf793bf commit 191a641

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/events/SDL_keyboard.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ void SDL_RemoveKeyboard(SDL_KeyboardID keyboardID, bool send_event)
160160
SDL_free(SDL_keyboards[keyboard_index].name);
161161

162162
if (keyboard_index != SDL_keyboard_count - 1) {
163-
SDL_memcpy(&SDL_keyboards[keyboard_index], &SDL_keyboards[keyboard_index + 1], (SDL_keyboard_count - keyboard_index - 1) * sizeof(SDL_keyboards[keyboard_index]));
163+
SDL_memmove(&SDL_keyboards[keyboard_index], &SDL_keyboards[keyboard_index + 1], (SDL_keyboard_count - keyboard_index - 1) * sizeof(SDL_keyboards[keyboard_index]));
164164
}
165165
--SDL_keyboard_count;
166166

src/events/SDL_mouse.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ void SDL_RemoveMouse(SDL_MouseID mouseID, bool send_event)
328328
SDL_free(SDL_mice[mouse_index].name);
329329

330330
if (mouse_index != SDL_mouse_count - 1) {
331-
SDL_memcpy(&SDL_mice[mouse_index], &SDL_mice[mouse_index + 1], (SDL_mouse_count - mouse_index - 1) * sizeof(SDL_mice[mouse_index]));
331+
SDL_memmove(&SDL_mice[mouse_index], &SDL_mice[mouse_index + 1], (SDL_mouse_count - mouse_index - 1) * sizeof(SDL_mice[mouse_index]));
332332
}
333333
--SDL_mouse_count;
334334

@@ -339,7 +339,7 @@ void SDL_RemoveMouse(SDL_MouseID mouseID, bool send_event)
339339
if (source->mouseID == mouseID) {
340340
SDL_free(source->clickstate);
341341
if (i != mouse->num_sources - 1) {
342-
SDL_memcpy(&mouse->sources[i], &mouse->sources[i + 1], (mouse->num_sources - i - 1) * sizeof(mouse->sources[i]));
342+
SDL_memmove(&mouse->sources[i], &mouse->sources[i + 1], (mouse->num_sources - i - 1) * sizeof(mouse->sources[i]));
343343
}
344344
--mouse->num_sources;
345345
break;

0 commit comments

Comments
 (0)