summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego 'Flameeyes' Pettenò <flameeyes@gmail.com>2008-05-09 18:36:28 +0200
committerDiego 'Flameeyes' Pettenò <flameeyes@gmail.com>2008-05-09 18:36:28 +0200
commit8532f9356cdbd6585c5d9eaf5d92588ae7ddecbe (patch)
treef83bcb762ea1f2d1d797e0779c72909189dc6da5
parent4384f0b14a658b4179cedf77c2d6c2718610017b (diff)
downloadxine-lib-8532f9356cdbd6585c5d9eaf5d92588ae7ddecbe.tar.gz
xine-lib-8532f9356cdbd6585c5d9eaf5d92588ae7ddecbe.tar.bz2
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.
-rw-r--r--src/input/input_cdda.c22
-rw-r--r--src/xine-engine/load_plugins.c4
2 files changed, 7 insertions, 19 deletions
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);
}
}
}
diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c
index d08837dc5..09474082e 100644
--- a/src/xine-engine/load_plugins.c
+++ b/src/xine-engine/load_plugins.c
@@ -313,7 +313,6 @@ static void _insert_node (xine_t *this,
const input_info_t *input_old;
uint32_t *types;
char key[80];
- char desc[100];
int i;
_x_assert(list);
@@ -378,12 +377,11 @@ static void _insert_node (xine_t *this,
entry->priority = decoder_new->priority = decoder_old->priority;
snprintf(key, sizeof(key), "engine.decoder_priorities.%s", info->id);
- snprintf(desc, sizeof(desc), _("priority for %s decoder"), info->id);
/* write the description on the heap because the config system
* does not strdup() it, so we have to provide a different pointer
* for each decoder */
for (i = 0; catalog->prio_desc[i]; i++);
- catalog->prio_desc[i] = strdup(desc);
+ asprintf(&catalog->prio_desc[i], _("priority for %s decoder"), info->id);
this->config->register_num (this->config,
key,
0,