From c3744b6736ce45c1c700b7f026fb0acfb0069a6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Wed, 7 May 2008 17:49:47 +0200 Subject: Use asprintf() rather than malloc() + sprintf(). Using asprintf() instead of malloc() + sprintf() reduces the lines of code in xine-lib (moving the allocation to the C library or asprintf replacement), makes it safer to access the string and can also improve performance whenever the value returned by a function was used as parameter, as before it had to run the function twice in almost every case (once for strlen(), once for sprintf()). --- src/xine-engine/configfile.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/xine-engine/configfile.c') diff --git a/src/xine-engine/configfile.c b/src/xine-engine/configfile.c index ed3d2fcfb..ad23f3b30 100644 --- a/src/xine-engine/configfile.c +++ b/src/xine-engine/configfile.c @@ -369,8 +369,7 @@ static const char *config_translate_key (const char *key) { */ if (!strncmp (key, "decoder.", 8) && !strcmp (key + (trans = strlen (key)) - 9, "_priority")) { - newkey = realloc (newkey, trans + 27 - 17); /* diff. in string lengths */ - sprintf (newkey, "engine.decoder_priorities.%.*s", trans - 17, key + 8); + asprintf (&newkey, "engine.decoder_priorities.%.*s", trans - 17, key + 8); return newkey; } -- cgit v1.2.3