Przeglądaj źródła

DOS & Tray: Don't do NULL-checks before SDL_free()

Eddy Jansson 1 miesiąc temu
rodzic
commit
70159c34f6

+ 2 - 6
src/audio/dos/SDL_dosaudio_sb.c

@@ -485,12 +485,8 @@ static void DOSSOUNDBLASTER_CloseDevice(SDL_AudioDevice *device)
         }
 
         // Free ring buffer resources.
-        if (hidden->ring_buffer) {
-            SDL_free(hidden->ring_buffer);
-        }
-        if (hidden->staging_buffer) {
-            SDL_free(hidden->staging_buffer);
-        }
+        SDL_free(hidden->ring_buffer);
+        SDL_free(hidden->staging_buffer);
 
         // Clear ISR-visible statics.
         isr_ring_buffer = NULL;

+ 1 - 3
src/thread/dos/SDL_sysmutex.c

@@ -48,9 +48,7 @@ SDL_Mutex *SDL_CreateMutex(void)
 
 void SDL_DestroyMutex(SDL_Mutex *mutex)
 {
-    if (mutex) {
-        SDL_free(mutex);
-    }
+    SDL_free(mutex);
 }
 
 void SDL_LockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS

+ 1 - 3
src/thread/dos/SDL_syssem.c

@@ -44,9 +44,7 @@ SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value)
 
 void SDL_DestroySemaphore(SDL_Semaphore *sem)
 {
-    if (sem) {
-        SDL_free(sem);
-    }
+    SDL_free(sem);
 }
 
 bool SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS)

+ 3 - 9
src/tray/unix/SDL_dbustray.c

@@ -561,9 +561,7 @@ void DestroyMenu(SDL_TrayMenu *menu)
         SDL_ListClear(&menu_dbus->menu);
     }
 
-    if (menu_dbus->array_representation) {
-        SDL_free(menu_dbus->array_representation);
-    }
+    SDL_free(menu_dbus->array_representation);
 
     SDL_free(menu_dbus);
     SDL_free(menu);
@@ -656,9 +654,7 @@ void SetTrayTooltip(SDL_Tray *tray, const char *text)
     driver = (SDL_TrayDriverDBus *)tray->driver->internal;
     tray_dbus = (SDL_TrayDBus *)tray->internal;
 
-    if (tray_dbus->tooltip) {
-        SDL_free(tray_dbus->tooltip);
-    }
+    SDL_free(tray_dbus->tooltip);
 
     if (text) {
         tray_dbus->tooltip = SDL_strdup(text);
@@ -907,9 +903,7 @@ SDL_TrayEntry **GetTrayEntries(SDL_TrayMenu *menu, int *count)
 
     menu_dbus = (SDL_TrayMenuDBus *)menu->internal;
 
-    if (menu_dbus->array_representation) {
-        SDL_free(menu_dbus->array_representation);
-    }
+    SDL_free(menu_dbus->array_representation);
 
     sz = SDL_ListCountEntries(&menu_dbus->menu);
     array_representation = SDL_calloc(sz + 1, sizeof(SDL_TrayEntry *));