From 8532f9356cdbd6585c5d9eaf5d92588ae7ddecbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Fri, 9 May 2008 18:36:28 +0200 Subject: Use asprintf() rather than sn?printf() + strn?dup(). Instead of duplicating a buffer after using sn?printf() on it, use asprintf() directly on the final variable. --- src/input/input_cdda.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'src/input') diff --git a/src/input/input_cdda.c b/src/input/input_cdda.c index 990f4d8b0..92eca7559 100644 --- a/src/input/input_cdda.c +++ b/src/input/input_cdda.c @@ -1532,14 +1532,9 @@ static int _cdda_load_cached_cddb_infos(cdda_input_plugin_t *this) { int nyear; y = strstr(buffer, "YEAR:"); - if(y) { - if (sscanf(y+5, "%4d", &nyear) == 1) { - char year[5]; - - snprintf(year, 5, "%d", nyear); - if (this->cddb.disc_year == NULL) - this->cddb.disc_year = strdup(year); - } + if (y && this->cddb.disc_year == NULL) { + if (sscanf(y+5, "%4d", &nyear) == 1) + asprintf(&this->cddb.disc_year, "%d", nyear); } } } @@ -1875,14 +1870,9 @@ static int _cdda_cddb_retrieve(cdda_input_plugin_t *this) { int nyear; y = strstr(buffer, "YEAR:"); - if (y) { - if (sscanf(y+5, "%4d", &nyear) == 1) { - char year[5]; - - snprintf(year, 5, "%d", nyear); - if (this->cddb.disc_year == NULL) - this->cddb.disc_year = strdup(year); - } + if (y && this->cddb.disc_year == NULL) { + if (sscanf(y+5, "%4d", &nyear) == 1) + asprintf(&this->cddb.disc_year, "%d", nyear); } } } -- cgit v1.2.3