Explorar o código

testaudio: fixed memory leak in SetTitleBar()

Sam Lantinga hai 8 meses
pai
achega
1d5f9c7b92
Modificáronse 1 ficheiros con 4 adicións e 10 borrados
  1. 4 10
      test/testaudio.c

+ 4 - 10
test/testaudio.c

@@ -115,7 +115,6 @@ static Uint64 app_ready_ticks = 0;
 static SDLTest_CommonState *state = NULL;
 
 static Thing *things = NULL;
-static char *current_titlebar = NULL;
 
 static Thing *mouseover_thing = NULL;
 static Thing *droppable_highlighted_thing = NULL;
@@ -135,19 +134,14 @@ static Texture *soundboard_levels_texture = NULL;
 
 static void SetTitleBar(const char *fmt, ...)
 {
-    char *newstr = NULL;
+    char *title = NULL;
     va_list ap;
     va_start(ap, fmt);
-    SDL_vasprintf(&newstr, fmt, ap);
+    SDL_vasprintf(&title, fmt, ap);
     va_end(ap);
 
-    if (newstr && (!current_titlebar || (SDL_strcmp(current_titlebar, newstr) != 0))) {
-        SDL_SetWindowTitle(state->windows[0], newstr);
-        SDL_free(current_titlebar);
-        current_titlebar = newstr;
-    } else {
-        SDL_free(newstr);
-    }
+    SDL_SetWindowTitle(state->windows[0], title);
+    SDL_free(title);
 }
 
 static void SetDefaultTitleBar(void)