decoder/gme,input/curl,...: use static buffers instead of g_strdup_printf()
This commit is contained in:
@@ -31,8 +31,6 @@
|
||||
#include "util/Domain.hxx"
|
||||
#include "LogV.hxx"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
@@ -84,10 +82,11 @@ mpd_ffmpeg_log_callback(gcc_unused void *ptr, int level,
|
||||
cls = *(const AVClass *const*)ptr;
|
||||
|
||||
if (cls != NULL) {
|
||||
char *domain = g_strconcat(ffmpeg_domain.GetName(), "/", cls->item_name(ptr), NULL);
|
||||
char domain[64];
|
||||
snprintf(domain, sizeof(domain), "%s/%s",
|
||||
ffmpeg_domain.GetName(), cls->item_name(ptr));
|
||||
const Domain d(domain);
|
||||
LogFormatV(d, import_ffmpeg_level(level), fmt, vl);
|
||||
g_free(domain);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,12 +350,10 @@ ffmpeg_probe(struct decoder *decoder, struct input_stream *is)
|
||||
|
||||
Error error;
|
||||
|
||||
unsigned char *buffer = (unsigned char *)g_malloc(BUFFER_SIZE);
|
||||
unsigned char buffer[BUFFER_SIZE];
|
||||
size_t nbytes = decoder_read(decoder, is, buffer, BUFFER_SIZE);
|
||||
if (nbytes <= PADDING || !is->LockSeek(0, SEEK_SET, error)) {
|
||||
g_free(buffer);
|
||||
return NULL;
|
||||
}
|
||||
if (nbytes <= PADDING || !is->LockSeek(0, SEEK_SET, error))
|
||||
return nullptr;
|
||||
|
||||
/* some ffmpeg parsers (e.g. ac3_parser.c) read a few bytes
|
||||
beyond the declared buffer limit, which makes valgrind
|
||||
@@ -369,10 +366,7 @@ ffmpeg_probe(struct decoder *decoder, struct input_stream *is)
|
||||
avpd.buf_size = nbytes;
|
||||
avpd.filename = is->uri.c_str();
|
||||
|
||||
AVInputFormat *format = av_probe_input_format(&avpd, true);
|
||||
g_free(buffer);
|
||||
|
||||
return format;
|
||||
return av_probe_input_format(&avpd, true);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -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);
|
||||
|
@@ -359,11 +359,12 @@ sidplay_scan_file(const char *path_fs,
|
||||
title="";
|
||||
|
||||
if(info.songs>1) {
|
||||
char *tag_title=g_strdup_printf("%s (%d/%d)",
|
||||
title, song_num, info.songs);
|
||||
char tag_title[1024];
|
||||
snprintf(tag_title, sizeof(tag_title),
|
||||
"%s (%d/%d)",
|
||||
title, song_num, info.songs);
|
||||
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, title);
|
||||
|
||||
@@ -373,9 +374,9 @@ sidplay_scan_file(const char *path_fs,
|
||||
info.infoString[1]);
|
||||
|
||||
/* track */
|
||||
char *track=g_strdup_printf("%d", song_num);
|
||||
char track[16];
|
||||
sprintf(track, "%d", song_num);
|
||||
tag_handler_invoke_tag(handler, handler_ctx, TAG_TRACK, track);
|
||||
g_free(track);
|
||||
|
||||
/* time */
|
||||
int song_len=get_song_length(path_fs);
|
||||
|
Reference in New Issue
Block a user