diff options
author | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2008-05-07 17:49:47 +0200 |
---|---|---|
committer | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2008-05-07 17:49:47 +0200 |
commit | c3744b6736ce45c1c700b7f026fb0acfb0069a6d (patch) | |
tree | f92efb8a27043f24f2ef5d4a916f23a769634b15 /src/input/input_dvd.c | |
parent | 4527fd438b39dc312c69839f051e0a2ac0046356 (diff) | |
download | xine-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/input/input_dvd.c')
-rw-r--r-- | src/input/input_dvd.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/input/input_dvd.c b/src/input/input_dvd.c index 441a4544b..ef5f1e055 100644 --- a/src/input/input_dvd.c +++ b/src/input/input_dvd.c @@ -1369,10 +1369,7 @@ check_solaris_vold_device(dvd_input_class_t *this) (volume_action = getenv("VOLUME_ACTION")) != NULL && strcmp(volume_action, "insert") == 0) { - device = malloc(strlen(volume_device) + strlen(volume_name) + 2); - if (device == NULL) - return; - sprintf(device, "%s/%s", volume_device, volume_name); + asprintf(&device, "%s/%s", volume_device, volume_name); if (stat(device, &stb) != 0 || !S_ISCHR(stb.st_mode)) { free(device); return; @@ -1820,8 +1817,7 @@ static void *init_class (xine_t *xine, void *data) { "playing scrambled DVDs."), 20, NULL, NULL); xine_setenv("DVDCSS_METHOD", decrypt_modes[mode], 0); - css_cache_default = (char *)malloc(strlen(xine_get_homedir()) + 10); - sprintf(css_cache_default, "%s/.dvdcss/", xine_get_homedir()); + asprintf(&css_cache_default, "%s/.dvdcss/", xine_get_homedir()); css_cache = config->register_filename(config, "media.dvd.css_cache_path", css_cache_default, XINE_CONFIG_STRING_IS_DIRECTORY_NAME, _("path to the title key cache"), _("Since cracking the copy protection of scrambled DVDs can " |