diff options
Diffstat (limited to 'src/input')
-rw-r--r-- | src/input/http_helper.c | 3 | ||||
-rw-r--r-- | src/input/input_dvd.c | 8 | ||||
-rw-r--r-- | src/input/input_file.c | 15 | ||||
-rw-r--r-- | src/input/input_http.c | 3 | ||||
-rw-r--r-- | src/input/input_rtsp.c | 3 | ||||
-rw-r--r-- | src/input/input_smb.c | 30 | ||||
-rw-r--r-- | src/input/librtsp/rtsp.c | 26 |
7 files changed, 27 insertions, 61 deletions
diff --git a/src/input/http_helper.c b/src/input/http_helper.c index 4883763b0..279d3ff05 100644 --- a/src/input/http_helper.c +++ b/src/input/http_helper.c @@ -240,8 +240,7 @@ char *_x_canonicalise_url (const char *base, const char *url) { ++cut; } base_length = cut ? (size_t)(cut - base) : strlen (base); - ret = malloc (base_length + strlen (url) + 1); - sprintf (ret, "%.*s%s", (int)base_length, base, url); + asprintf (&ret, "%.*s%s", (int)base_length, base, url); return ret; } 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 " diff --git a/src/input/input_file.c b/src/input/input_file.c index 3364ef46b..f07c9e93c 100644 --- a/src/input/input_file.c +++ b/src/input/input_file.c @@ -708,11 +708,8 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen, } else { - dir_files[num_dir_files].mrl = (char *) - xine_xmalloc(strlen(current_dir_slashed) + 1 + strlen(pdirent->d_name) + 1); - dir_files[num_dir_files].origin = strdup(current_dir); - sprintf(dir_files[num_dir_files].mrl, "%s%s", + asprintf(&(dir_files[num_dir_files].mrl), "%s%s", current_dir_slashed, pdirent->d_name); dir_files[num_dir_files].link = NULL; dir_files[num_dir_files].type = get_file_type(fullfilename, current_dir, this->xine); @@ -746,11 +743,8 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen, /* if user don't want to see hidden files, ignore them */ if(this->show_hidden_files) { - hide_files[num_hide_files].mrl = (char *) - xine_xmalloc(strlen(current_dir_slashed) + 1 + strlen(pdirent->d_name) + 1); - hide_files[num_hide_files].origin = strdup(current_dir); - sprintf(hide_files[num_hide_files].mrl, "%s%s", + asprintf(&(hide_files[num_hide_files].mrl), "%s%s", current_dir_slashed, pdirent->d_name); hide_files[num_hide_files].link = NULL; hide_files[num_hide_files].type = get_file_type(fullfilename, current_dir, this->xine); @@ -782,11 +776,8 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen, } /* So a *normal* one. */ else { - norm_files[num_norm_files].mrl = (char *) - xine_xmalloc(strlen(current_dir_slashed) + 1 + strlen(pdirent->d_name) + 1); - norm_files[num_norm_files].origin = strdup(current_dir); - sprintf(norm_files[num_norm_files].mrl, "%s%s", + asprintf(&(norm_files[num_norm_files].mrl), "%s%s", current_dir_slashed, pdirent->d_name); norm_files[num_norm_files].link = NULL; norm_files[num_norm_files].type = get_file_type(fullfilename, current_dir, this->xine); diff --git a/src/input/input_http.c b/src/input/input_http.c index 93198a06e..0e9345731 100644 --- a/src/input/input_http.c +++ b/src/input/input_http.c @@ -1025,8 +1025,7 @@ static input_plugin_t *http_class_get_instance (input_class_t *cls_gen, xine_str this = calloc(1, sizeof(http_input_plugin_t)); if (!strncasecmp (mrl, "peercast://pls/", 15)) { - this->mrl = xine_xmalloc (30 + strlen(mrl) - 15); - sprintf (this->mrl, "http://127.0.0.1:7144/stream/%s", mrl+15); + asprintf (&this->mrl, "http://127.0.0.1:7144/stream/%s", mrl+15); } else { this->mrl = strdup (mrl); } diff --git a/src/input/input_rtsp.c b/src/input/input_rtsp.c index 8491d0a5d..db16c9bc6 100644 --- a/src/input/input_rtsp.c +++ b/src/input/input_rtsp.c @@ -254,8 +254,7 @@ static input_plugin_t *rtsp_class_get_instance (input_class_t *cls_gen, xine_str /* since we handle only real streams yet, we can savely add * an .rm extention to force handling by demux_real. */ - this->public_mrl = calloc(strlen(this->mrl)+10, sizeof (char)); - sprintf(this->public_mrl, "%s.rm", this->mrl); + asprintf(&this->public_mrl, "%s.rm", this->mrl); this->nbc = nbc_init (stream); diff --git a/src/input/input_smb.c b/src/input/input_smb.c index c4706d9f3..dbab772c9 100644 --- a/src/input/input_smb.c +++ b/src/input/input_smb.c @@ -265,9 +265,7 @@ static xine_mrl_t **smb_class_get_dir (input_class_t *this_gen, dir_files[num_dir_files].link = NULL; dir_files[num_dir_files].type = mrl_file | mrl_file_directory; dir_files[num_dir_files].origin = strdup(current_path); - dir_files[num_dir_files].mrl = (char *) xine_xmalloc( - strlen(current_path) + 1 + strlen(pdirent->name) + 1); - sprintf(dir_files[num_dir_files].mrl, "%s/%s", current_path, pdirent->name); + asprintf(&(dir_files[num_dir_files].mrl), "%s/%s", current_path, pdirent->name); dir_files[num_dir_files].size = pdirent->dirlen; num_dir_files ++; }else if (pdirent->smbc_type == SMBC_SERVER){ @@ -275,17 +273,14 @@ static xine_mrl_t **smb_class_get_dir (input_class_t *this_gen, dir_files[num_dir_files].link = NULL; dir_files[num_dir_files].type = mrl_file | mrl_file_directory; dir_files[num_dir_files].origin = strdup("smb:/"); - dir_files[num_dir_files].mrl = (char *) xine_xmalloc(strlen("smb:/") + 4); - sprintf(dir_files[num_dir_files].mrl, "%s/%s", "smb:/", ".."); + asprintf(&(dir_files[num_dir_files].mrl), "%s/%s", "smb:/", ".."); dir_files[num_dir_files].size = pdirent->dirlen; num_dir_files ++; } dir_files[num_dir_files].link = NULL; dir_files[num_dir_files].type = mrl_file | mrl_file_directory; dir_files[num_dir_files].origin = strdup("smb:/"); - dir_files[num_dir_files].mrl = - (char *) xine_xmalloc(strlen("smb:/") + 1 + strlen(pdirent->name) + 1); - sprintf(dir_files[num_dir_files].mrl, "%s/%s", "smb:/", pdirent->name); + asprintf(*(dir_files[num_dir_files].mrl), "%s/%s", "smb:/", pdirent->name); dir_files[num_dir_files].size = pdirent->dirlen; num_dir_files ++; } else if (pdirent->smbc_type == SMBC_FILE_SHARE){ @@ -293,9 +288,7 @@ static xine_mrl_t **smb_class_get_dir (input_class_t *this_gen, dir_files[num_dir_files].link = NULL; dir_files[num_dir_files].type = mrl_file | mrl_file_directory; dir_files[num_dir_files].origin = strdup(current_path); - dir_files[num_dir_files].mrl = (char *) xine_xmalloc( - strlen(current_path) + 3); - sprintf(dir_files[num_dir_files].mrl, "%s/%s", current_path, ".."); + asprintf(&(dir_files[num_dir_files].mrl), "%s/%s", current_path, ".."); dir_files[num_dir_files].type |= mrl_file_directory; dir_files[num_dir_files].size = pdirent->dirlen; num_dir_files ++; @@ -304,9 +297,7 @@ static xine_mrl_t **smb_class_get_dir (input_class_t *this_gen, dir_files[num_dir_files].link = NULL; dir_files[num_dir_files].type = mrl_file | mrl_file_directory; dir_files[num_dir_files].origin = strdup(current_path); - dir_files[num_dir_files].mrl = (char *) xine_xmalloc( - strlen(current_path) + 1 + strlen(pdirent->name) + 1); - sprintf(dir_files[num_dir_files].mrl, "%s/%s", current_path, pdirent->name); + asprintf(&(dir_files[num_dir_files].mrl), "%s/%s", current_path, pdirent->name); dir_files[num_dir_files].size = pdirent->dirlen; num_dir_files ++; } @@ -314,18 +305,14 @@ static xine_mrl_t **smb_class_get_dir (input_class_t *this_gen, dir_files[num_dir_files].link = NULL; dir_files[num_dir_files].type = mrl_file | mrl_file_directory; dir_files[num_dir_files].origin = strdup(current_path); - dir_files[num_dir_files].mrl = - (char *) xine_xmalloc(strlen(current_path) + 1 + strlen(pdirent->name) + 1); - sprintf(dir_files[num_dir_files].mrl, "%s/%s", current_path, pdirent->name); + asprintf(&(dir_files[num_dir_files].mrl), "%s/%s", current_path, pdirent->name); dir_files[num_dir_files].size = pdirent->dirlen; num_dir_files ++; }else if (pdirent->smbc_type == SMBC_FILE){ norm_files[num_norm_files].link = NULL; norm_files[num_norm_files].type = mrl_file | mrl_file_normal; norm_files[num_norm_files].origin = strdup(current_path); - norm_files[num_norm_files].mrl = - (char *) xine_xmalloc(strlen(current_path) + 1 + strlen(pdirent->name) + 1); - sprintf(norm_files[num_norm_files].mrl, "%s/%s", current_path, pdirent->name); + asprintf(&(norm_files[num_norm_files].mrl), "%s/%s", current_path, pdirent->name); norm_files[num_norm_files].size = pdirent->dirlen; num_norm_files ++; } @@ -335,8 +322,7 @@ static xine_mrl_t **smb_class_get_dir (input_class_t *this_gen, if (num_dir_files == 0) { dir_files[num_dir_files].link = NULL; dir_files[num_dir_files].origin = strdup(current_path); - dir_files[num_dir_files].mrl = (char *) xine_xmalloc(strlen(current_path) + 4); - sprintf(dir_files[num_dir_files].mrl, "%s/%s", current_path, ".."); + asprintf(&(dir_files[num_dir_files].mrl), "%s/%s", current_path, ".."); dir_files[num_dir_files].type = mrl_file | mrl_file_directory; dir_files[num_dir_files].size = 0; num_dir_files ++; diff --git a/src/input/librtsp/rtsp.c b/src/input/librtsp/rtsp.c index 530ffc6cf..beb77d8b4 100644 --- a/src/input/librtsp/rtsp.c +++ b/src/input/librtsp/rtsp.c @@ -21,6 +21,10 @@ * *not* RFC 2326 compilant yet. */ +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + #include <unistd.h> #include <stdio.h> #include <assert.h> @@ -173,9 +177,7 @@ static void rtsp_send_request(rtsp_t *s, const char *type, const char *what) { char **payload=s->scheduled; char *buf; - buf = malloc(strlen(type)+strlen(what)+strlen(rtsp_protocol_version)+3); - - sprintf(buf,"%s %s %s",type, what, rtsp_protocol_version); + asprintf(&buf,"%s %s %s",type, what, rtsp_protocol_version); rtsp_put(s,buf); free(buf); if (payload) @@ -200,8 +202,7 @@ static void rtsp_schedule_standard(rtsp_t *s) { if (s->session) { char *buf; - buf = malloc(strlen(s->session)+15); - sprintf(buf, "Session: %s", s->session); + asprintf(&buf, "Session: %s", s->session); rtsp_schedule_field(s, buf); free(buf); } @@ -304,8 +305,7 @@ int rtsp_request_options(rtsp_t *s, const char *what) { buf=strdup(what); } else { - buf = malloc(sizeof(char)*(strlen(s->host)+16)); - sprintf(buf,"rtsp://%s:%i", s->host, s->port); + asprintf(&buf,"rtsp://%s:%i", s->host, s->port); } rtsp_send_request(s,"OPTIONS",buf); free(buf); @@ -321,8 +321,7 @@ int rtsp_request_describe(rtsp_t *s, const char *what) { buf=strdup(what); } else { - buf = malloc(sizeof(char)*(strlen(s->host)+strlen(s->path)+16)); - sprintf(buf,"rtsp://%s:%i/%s", s->host, s->port, s->path); + asprintf(&buf,"rtsp://%s:%i/%s", s->host, s->port, s->path); } rtsp_send_request(s,"DESCRIBE",buf); free(buf); @@ -345,8 +344,7 @@ int rtsp_request_setparameter(rtsp_t *s, const char *what) { buf=strdup(what); } else { - buf = malloc(sizeof(char)*(strlen(s->host)+strlen(s->path)+16)); - sprintf(buf,"rtsp://%s:%i/%s", s->host, s->port, s->path); + asprintf(&buf,"rtsp://%s:%i/%s", s->host, s->port, s->path); } rtsp_send_request(s,"SET_PARAMETER",buf); free(buf); @@ -362,8 +360,7 @@ int rtsp_request_play(rtsp_t *s, const char *what) { buf=strdup(what); } else { - buf = malloc(sizeof(char)*(strlen(s->host)+strlen(s->path)+16)); - sprintf(buf,"rtsp://%s:%i/%s", s->host, s->port, s->path); + asprintf(&buf,"rtsp://%s:%i/%s", s->host, s->port, s->path); } rtsp_send_request(s,"PLAY",buf); free(buf); @@ -412,8 +409,7 @@ int rtsp_read_data(rtsp_t *s, char *buffer, unsigned int size) { } /* lets make the server happy */ rtsp_put(s, "RTSP/1.0 451 Parameter Not Understood"); - rest = malloc(sizeof(char)*17); - sprintf(rest,"CSeq: %u", seq); + asprintf(&rest,"CSeq: %u", seq); rtsp_put(s, rest); free(rest); rtsp_put(s, ""); |