Fix some issues caught by check_stdlib_usage.py

This commit is contained in:
Sam Lantinga
2023-06-27 06:18:45 -07:00
parent e8d2ccbc1c
commit c065a9b128
15 changed files with 41 additions and 39 deletions

View File

@@ -42,7 +42,7 @@
#define RETIFIOCTLERR(x) \
if ((x) == -1) { \
free(input); \
SDL_free(input); \
input = NULL; \
return NULL; \
}
@@ -424,13 +424,13 @@ static SDL_WSCONS_input_data *SDL_WSCONS_Init_Keyboard(const char *dev)
}
input->fd = open(dev, O_RDWR | O_NONBLOCK | O_CLOEXEC);
if (input->fd == -1) {
free(input);
SDL_free(input);
input = NULL;
return NULL;
}
input->keymap.map = SDL_calloc(sizeof(struct wscons_keymap), KS_NUMKEYCODES);
if (input->keymap.map == NULL) {
free(input);
SDL_free(input);
return NULL;
}
input->keymap.maplen = KS_NUMKEYCODES;
@@ -471,7 +471,7 @@ void SDL_WSCONS_Quit()
close(input->fd);
input->fd = -1;
}
free(input);
SDL_free(input);
input = NULL;
}
inputs[i] = NULL;

View File

@@ -46,7 +46,7 @@ SDL_WSCONS_mouse_input_data *SDL_WSCONS_Init_Mouse()
}
mouseInputData->fd = open("/dev/wsmouse", O_RDWR | O_NONBLOCK | O_CLOEXEC);
if (mouseInputData->fd == -1) {
free(mouseInputData);
SDL_free(mouseInputData);
return NULL;
}
#ifdef WSMOUSEIO_SETMODE
@@ -129,5 +129,5 @@ void SDL_WSCONS_Quit_Mouse(SDL_WSCONS_mouse_input_data *inputData)
return;
}
close(inputData->fd);
free(inputData);
SDL_free(inputData);
}