Christoph Mallon: Remove pointless if (x) before SDL_free(x)

This commit is contained in:
Sam Lantinga
2013-08-29 08:29:21 -07:00
parent 1d2c7796ae
commit f79fc33a39
63 changed files with 157 additions and 349 deletions

View File

@@ -437,22 +437,13 @@ SDL_JoystickClose(SDL_Joystick * joystick)
joysticklist = joysticklist->next;
}
if (joystick->name)
SDL_free(joystick->name);
SDL_free(joystick->name);
/* Free the data associated with this joystick */
if (joystick->axes) {
SDL_free(joystick->axes);
}
if (joystick->hats) {
SDL_free(joystick->hats);
}
if (joystick->balls) {
SDL_free(joystick->balls);
}
if (joystick->buttons) {
SDL_free(joystick->buttons);
}
SDL_free(joystick->axes);
SDL_free(joystick->hats);
SDL_free(joystick->balls);
SDL_free(joystick->buttons);
SDL_free(joystick);
}

View File

@@ -231,12 +231,8 @@ extern "C"
if (joystick->hwdata) {
joystick->hwdata->stick->Close();
delete joystick->hwdata->stick;
if (joystick->hwdata->new_hats) {
SDL_free(joystick->hwdata->new_hats);
}
if (joystick->hwdata->new_axes) {
SDL_free(joystick->hwdata->new_axes);
}
SDL_free(joystick->hwdata->new_hats);
SDL_free(joystick->hwdata->new_axes);
SDL_free(joystick->hwdata);
joystick->hwdata = NULL;
}

View File

@@ -577,10 +577,8 @@ SDL_SYS_JoystickQuit(void)
int i;
for (i = 0; i < MAX_JOYS; i++) {
if (joynames[i] != NULL)
SDL_free(joynames[i]);
if (joydevnames[i] != NULL)
SDL_free(joydevnames[i]);
SDL_free(joynames[i]);
SDL_free(joydevnames[i]);
}
return;
@@ -657,9 +655,7 @@ report_alloc(struct report *r, struct report_desc *rd, int repind)
static void
report_free(struct report *r)
{
if (r->buf != NULL) {
SDL_free(r->buf);
}
SDL_free(r->buf);
r->status = SREPORT_UNINIT;
}

View File

@@ -834,7 +834,7 @@ void SDL_SYS_JoystickDetect()
pListNext = pCurList->pNext;
SDL_free(pCurList->joystickname);
SDL_free( pCurList );
SDL_free(pCurList);
pCurList = pListNext;
}
@@ -1559,10 +1559,8 @@ SDL_SYS_JoystickClose(SDL_Joystick * joystick)
IDirectInputDevice8_Release(joystick->hwdata->InputDevice);
}
if (joystick->hwdata != NULL) {
/* free system specific hardware data */
SDL_free(joystick->hwdata);
}
/* free system specific hardware data */
SDL_free(joystick->hwdata);
joystick->closed = 1;
}

View File

@@ -384,11 +384,9 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
void
SDL_SYS_JoystickClose(SDL_Joystick * joystick)
{
if (joystick->hwdata != NULL) {
/* free system specific hardware data */
SDL_free(joystick->hwdata);
joystick->hwdata = NULL;
}
/* free system specific hardware data */
SDL_free(joystick->hwdata);
joystick->hwdata = NULL;
}
/* Function to perform any system-specific joystick related cleanup */
@@ -397,10 +395,8 @@ SDL_SYS_JoystickQuit(void)
{
int i;
for (i = 0; i < MAX_JOYSTICKS; i++) {
if (SYS_JoystickName[i] != NULL) {
SDL_free(SYS_JoystickName[i]);
SYS_JoystickName[i] = NULL;
}
SDL_free(SYS_JoystickName[i]);
SYS_JoystickName[i] = NULL;
}
}