Mercurial > mplayer.hg
changeset 3612:a1522fa7728a
x = malloc(strlen(s) + c) ... strcpy(x, s)
replaced by
x = strdup(s)
Note: sometimes c was 0 and that was a bug
Note2: code still has to be added to check the returned value of these funcs
author | pl |
---|---|
date | Wed, 19 Dec 2001 13:03:22 +0000 |
parents | 178c562948ff |
children | 8a82dca566bc |
files | libmpdemux/demux_viv.c libmpdemux/tv.c libmpdemux/url.c |
diffstat | 3 files changed, 7 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpdemux/demux_viv.c Wed Dec 19 12:54:06 2001 +0000 +++ b/libmpdemux/demux_viv.c Wed Dec 19 13:03:22 2001 +0000 @@ -191,26 +191,22 @@ if (!strcmp(opt, "Title")) { demux_info_add(demux, "name", param); - priv->title = malloc(strlen(param)); - strcpy(priv->title, param); + priv->title = strdup(param); } if (!strcmp(opt, "Author")) { demux_info_add(demux, "author", param); - priv->author = malloc(strlen(param)); - strcpy(priv->author, param); + priv->author = strdup(param); } if (!strcmp(opt, "Copyright")) { demux_info_add(demux, "copyright", param); - priv->copyright = malloc(strlen(param)); - strcpy(priv->copyright, param); + priv->copyright = strdup(param); } if (!strcmp(opt, "Producer")) { demux_info_add(demux, "encoder", param); - priv->producer = malloc(strlen(param)); - strcpy(priv->producer, param); + priv->producer = strdup(param); } /* get next token */
--- a/libmpdemux/tv.c Wed Dec 19 12:54:06 2001 +0000 +++ b/libmpdemux/tv.c Wed Dec 19 13:03:22 2001 +0000 @@ -343,8 +343,7 @@ mp_msg(MSGT_TV, MSGL_INFO, " comment: %s\n", tvh->info->comment); params = malloc(sizeof(tvi_param_t)*2); - params[0].opt = malloc(strlen("input")); - sprintf((char *)params[0].opt, "input"); + params[0].opt = strdup("input"); params[0].value = malloc(sizeof(int)); (int)*(void **)params[0].value = tv_param_input; params[1].opt = params[1].value = NULL;
--- a/libmpdemux/url.c Wed Dec 19 12:54:06 2001 +0000 +++ b/libmpdemux/url.c Wed Dec 19 13:03:22 2001 +0000 @@ -29,12 +29,11 @@ memset( Curl, 0, sizeof(URL_t) ); // Copy the url in the URL container - Curl->url = (char*)malloc(strlen(url)+1); + Curl->url = strdup(url); if( Curl->url==NULL ) { printf("Memory allocation failed!\n"); return NULL; } - strcpy(Curl->url, url); // extract the protocol ptr1 = strstr(url, "://"); @@ -86,12 +85,11 @@ // check if it's not a trailing '/' if( strlen(ptr2)>1 ) { // copy the path/filename in the URL container - Curl->file = (char*)malloc(strlen(ptr2)+1); + Curl->file = strdup(ptr2); if( Curl->file==NULL ) { printf("Memory allocation failed!\n"); return NULL; } - strcpy(Curl->file, ptr2); } } // Check if a filenme was given or set, else set it with '/'