Fixed freeing strings created by strdup() with SDL_free(). This only worked on platforms where SDL_free() wraps free().
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
diff --git a/src/joystick/bsd/SDL_sysjoystick.c b/src/joystick/bsd/SDL_sysjoystick.c
index 509d43f..ddc899f 100644
--- a/src/joystick/bsd/SDL_sysjoystick.c
+++ b/src/joystick/bsd/SDL_sysjoystick.c
@@ -179,7 +179,7 @@ SDL_SYS_JoystickInit(void)
SDL_snprintf(s, SDL_arraysize(s), "/dev/uhid%d", i);
- joynames[SDL_SYS_numjoysticks] = strdup(s);
+ joynames[SDL_SYS_numjoysticks] = SDL_strdup(s);
if (SDL_SYS_JoystickOpen(&nj, SDL_SYS_numjoysticks) == 0) {
SDL_SYS_JoystickClose(&nj);
@@ -193,7 +193,7 @@ SDL_SYS_JoystickInit(void)
SDL_snprintf(s, SDL_arraysize(s), "/dev/joy%d", i);
fd = open(s, O_RDONLY);
if (fd != -1) {
- joynames[SDL_SYS_numjoysticks++] = strdup(s);
+ joynames[SDL_SYS_numjoysticks++] = SDL_strdup(s);
close(fd);
}
}
@@ -304,14 +304,14 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joy, int device_index)
}
joy->hwdata = hw;
hw->fd = fd;
- hw->path = strdup(path);
+ hw->path = SDL_strdup(path);
if (!SDL_strncmp(path, "/dev/joy", 8)) {
hw->type = BSDJOY_JOY;
joy->naxes = 2;
joy->nbuttons = 2;
joy->nhats = 0;
joy->nballs = 0;
- joydevnames[device_index] = strdup("Gameport joystick");
+ joydevnames[device_index] = SDL_strdup("Gameport joystick");
goto usbend;
} else {
hw->type = BSDJOY_UHID;
@@ -363,7 +363,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joy, int device_index)
str[i] = '\0';
asprintf(&new_name, "%s @ %s", str, path);
if (new_name != NULL) {
- free(joydevnames[SDL_SYS_numjoysticks]);
+ SDL_free(joydevnames[SDL_SYS_numjoysticks]);
joydevnames[SDL_SYS_numjoysticks] = new_name;
}
}
diff --git a/src/joystick/haiku/SDL_haikujoystick.cc b/src/joystick/haiku/SDL_haikujoystick.cc
index 3ec9ae1..a680189 100644
--- a/src/joystick/haiku/SDL_haikujoystick.cc
+++ b/src/joystick/haiku/SDL_haikujoystick.cc
@@ -74,8 +74,8 @@ extern "C"
if (joystick.Open(name) != B_ERROR) {
BString stick_name;
joystick.GetControllerName(&stick_name);
- SDL_joyport[SDL_SYS_numjoysticks] = strdup(name);
- SDL_joyname[SDL_SYS_numjoysticks] = strdup(stick_name.String());
+ SDL_joyport[SDL_SYS_numjoysticks] = SDL_strdup(name);
+ SDL_joyname[SDL_SYS_numjoysticks] = SDL_strdup(stick_name.String());
SDL_SYS_numjoysticks++;
joystick.Close();
}
diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c
index 45733fb..a377a8d 100644
--- a/src/video/wayland/SDL_waylandvideo.c
+++ b/src/video/wayland/SDL_waylandvideo.c
@@ -145,7 +145,7 @@ display_handle_geometry(void *data,
{
SDL_VideoDisplay *display = data;
- display->name = strdup(model);
+ display->name = SDL_strdup(model);
display->driverdata = output;
}