From 1434e5a22e82b4176c24c536a91eefa183b78516 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 19 Oct 2013 17:15:17 +0200 Subject: decoder/gme,input/curl,...: use static buffers instead of g_strdup_printf() --- src/decoder/GmeDecoderPlugin.cxx | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'src/decoder/GmeDecoderPlugin.cxx') diff --git a/src/decoder/GmeDecoderPlugin.cxx b/src/decoder/GmeDecoderPlugin.cxx index bbcc9618a..f735c55ba 100644 --- a/src/decoder/GmeDecoderPlugin.cxx +++ b/src/decoder/GmeDecoderPlugin.cxx @@ -53,10 +53,12 @@ get_container_name(const char *path_fs) { const char *subtune_suffix = uri_get_suffix(path_fs); char *path_container = g_strdup(path_fs); - char *pat = g_strconcat("*/" SUBTUNE_PREFIX "???.", - subtune_suffix, nullptr); + + char pat[64]; + snprintf(pat, sizeof(pat), "%s%s", + "*/" SUBTUNE_PREFIX "???.", + subtune_suffix); GPatternSpec *path_with_subtune = g_pattern_spec_new(pat); - g_free(pat); if (!g_pattern_match(path_with_subtune, strlen(path_container), path_container, nullptr)) { g_pattern_spec_free(path_with_subtune); @@ -79,10 +81,12 @@ static int get_song_num(const char *path_fs) { const char *subtune_suffix = uri_get_suffix(path_fs); - char *pat = g_strconcat("*/" SUBTUNE_PREFIX "???.", - subtune_suffix, nullptr); + + char pat[64]; + snprintf(pat, sizeof(pat), "%s%s", + "*/" SUBTUNE_PREFIX "???.", + subtune_suffix); GPatternSpec *path_with_subtune = g_pattern_spec_new(pat); - g_free(pat); if (g_pattern_match(path_with_subtune, strlen(path_fs), path_fs, nullptr)) { @@ -235,13 +239,13 @@ gme_scan_file(const char *path_fs, if (ti->song != nullptr) { if (gme_track_count(emu) > 1) { /* start numbering subtunes from 1 */ - char *tag_title = - g_strdup_printf("%s (%d/%d)", - ti->song, song_num + 1, - gme_track_count(emu)); + char tag_title[1024]; + snprintf(tag_title, sizeof(tag_title), + "%s (%d/%d)", + ti->song, song_num + 1, + gme_track_count(emu)); tag_handler_invoke_tag(handler, handler_ctx, TAG_TITLE, tag_title); - g_free(tag_title); } else tag_handler_invoke_tag(handler, handler_ctx, TAG_TITLE, ti->song); -- cgit v1.2.3