From 0e44b4ebf62514d35a42a6ec59698f7d614c9115 Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Mon, 10 Oct 2022 05:01:02 +0300 Subject: [PATCH] remove malloc'ing of sound_file and sound_wav descriptions --- src/sound_file.c | 16 +--------------- src/sound_wav.c | 21 ++------------------- 2 files changed, 3 insertions(+), 34 deletions(-) diff --git a/src/sound_file.c b/src/sound_file.c index 83b5730..8406941 100644 --- a/src/sound_file.c +++ b/src/sound_file.c @@ -17,7 +17,6 @@ static int swap_endian; static int init(struct options *options) { char **parm = options->driver_parm; - char *buf; swap_endian = 0; @@ -38,18 +37,6 @@ static int init(struct options *options) fd = stdout; } - if (strcmp(options->out_file, "-")) { - int len = strlen(sound_file.description) + - strlen(options->out_file) + 8; - if ((buf = (char *)malloc(len)) == NULL) - return -1; - snprintf(buf, len, "%s: %s", sound_file.description, - options->out_file); - sound_file.description = buf; - } else { - sound_file.description = xmp_strdup("stdout"); - } - return 0; } @@ -64,7 +51,6 @@ static void play(void *b, int len) static void deinit(void) { - free((void *)sound_file.description); if (fd && fd != stdout) { fclose(fd); } @@ -86,7 +72,7 @@ static void onresume(void) { } -static const char *const help[] = { +static const char * const help[] = { "endian=big", "Force big-endian 16-bit samples", "endian=little", "Force little-endian 16-bit samples", NULL diff --git a/src/sound_wav.c b/src/sound_wav.c index f9cb1dc..655dc1a 100644 --- a/src/sound_wav.c +++ b/src/sound_wav.c @@ -45,8 +45,6 @@ static void write_32l(FILE *f, unsigned int v) static int init(struct options *options) { - char *buf; - unsigned int len = 0; unsigned short chan; unsigned int sampling_rate, bytes_per_second; unsigned short bytes_per_frame, bits_per_sample; @@ -65,21 +63,8 @@ static int init(struct options *options) fd = stdout; } - if (strcmp(options->out_file, "-")) { - int len = strlen(sound_wav.description) + - strlen(options->out_file) + 8; - if ((buf = (char *)malloc(len)) == NULL) - return -1; - snprintf(buf, len, "%s: %s", sound_wav.description, - options->out_file); - sound_wav.description = buf; - } else { - sound_wav.description = xmp_strdup("WAV writer: stdout"); - len = -1; - } - fwrite("RIFF", 1, 4, fd); - write_32l(fd, len); + write_32l(fd, 0); /* will be written when finished */ fwrite("WAVE", 1, 4, fd); chan = options->format & XMP_FORMAT_MONO ? 1 : 2; @@ -107,7 +92,7 @@ static int init(struct options *options) write_16l(fd, bits_per_sample); fwrite("data", 1, 4, fd); - write_32l(fd, len); + write_32l(fd, 0); /* will be written when finished */ size = 0; @@ -136,8 +121,6 @@ static void deinit(void) fclose(fd); } fd = NULL; - - free((void *)sound_wav.description); } static void flush(void)