summaryrefslogtreecommitdiff
path: root/src/xine-engine/xine.c
diff options
context:
space:
mode:
authorDiego 'Flameeyes' Pettenò <flameeyes@gmail.com>2008-05-07 17:49:47 +0200
committerDiego 'Flameeyes' Pettenò <flameeyes@gmail.com>2008-05-07 17:49:47 +0200
commitc3744b6736ce45c1c700b7f026fb0acfb0069a6d (patch)
treef92efb8a27043f24f2ef5d4a916f23a769634b15 /src/xine-engine/xine.c
parent4527fd438b39dc312c69839f051e0a2ac0046356 (diff)
downloadxine-lib-c3744b6736ce45c1c700b7f026fb0acfb0069a6d.tar.gz
xine-lib-c3744b6736ce45c1c700b7f026fb0acfb0069a6d.tar.bz2
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()).
Diffstat (limited to 'src/xine-engine/xine.c')
-rw-r--r--src/xine-engine/xine.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c
index c22391642..92f7a2603 100644
--- a/src/xine-engine/xine.c
+++ b/src/xine-engine/xine.c
@@ -1634,8 +1634,7 @@ static void config_save_cb (void *this_gen, xine_cfg_entry_t *entry) {
xine_t *this = (xine_t *)this_gen;
char *homedir_trail_slash;
- homedir_trail_slash = (char *)malloc(strlen(xine_get_homedir()) + 2);
- sprintf(homedir_trail_slash, "%s/", xine_get_homedir());
+ asprintf(&homedir_trail_slash, "%s/", xine_get_homedir());
if (entry->str_value[0] &&
(entry->str_value[0] != '/' || strstr(entry->str_value, "/.") ||
strcmp(entry->str_value, xine_get_homedir()) == 0 ||