summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2021-03-18 16:30:27 (EDT)
committer P. J. McDermott <pj@pehjota.net>2021-03-18 16:30:27 (EDT)
commitfeee60fa34b5442f10d306be8aaaf52563f88648 (patch)
treeb407ec0d9d3dd45f79be17d69ef3ff4a838fbf0a
parent1e047860d1e82b3f189d7b50493548e736cc2e05 (diff)
downloaddodge-balls-feee60fa34b5442f10d306be8aaaf52563f88648.zip
dodge-balls-feee60fa34b5442f10d306be8aaaf52563f88648.tar.gz
dodge-balls-feee60fa34b5442f10d306be8aaaf52563f88648.tar.bz2
main-menu: Save and free font path
-rw-r--r--src/main-menu.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/main-menu.c b/src/main-menu.c
index bfd4c3d..58f0a5d 100644
--- a/src/main-menu.c
+++ b/src/main-menu.c
@@ -27,7 +27,7 @@
#include "util.h"
static void
-_db_main_menu_title(const char *fonts_dir, SDL_Renderer *renderer)
+_db_main_menu_title(const char *font_path, SDL_Renderer *renderer)
{
SDL_Color color;
TTF_Font *font;
@@ -40,8 +40,7 @@ _db_main_menu_title(const char *fonts_dir, SDL_Renderer *renderer)
color.b = 0xFF;
color.a = 0xFF;
- font = TTF_OpenFont(
- db_strcat(fonts_dir, "/UbuntuTitling-Bold.ttf"), 48);
+ font = TTF_OpenFont(font_path, 48);
if (font == NULL) {
db_err("Failed to open font (%s)", TTF_GetError());
return;
@@ -73,14 +72,14 @@ void
db_main_menu(void)
{
const char *games_dir;
- const char *fonts_dir;
+ char *font_path;
SDL_Renderer *renderer;
struct db_game **games;
int n;
int i;
games_dir = db_get_games_dir();
- fonts_dir = db_get_fonts_dir();
+ font_path = db_strcat(db_get_fonts_dir(), "/UbuntuTitling-Bold.ttf");
renderer = db_get_renderer();
@@ -89,7 +88,7 @@ db_main_menu(void)
SDL_RenderClear(renderer);
/* Render title text */
- _db_main_menu_title(fonts_dir, renderer);
+ _db_main_menu_title(font_path, renderer);
/* Find games */
n = db_games_find(games_dir, &games);
@@ -105,4 +104,6 @@ db_main_menu(void)
SDL_RenderPresent(renderer);
SDL_Delay(1000);
+
+ free(font_path);
}