[PATCH] Replace two malloc+memset with calloc.

Clément Bœsch ubitux at gmail.com
Fri Dec 3 22:51:18 CET 2010


---
 stream/http.c |    3 +--
 stream/url.c  |    5 +----
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/stream/http.c b/stream/http.c
index 2fad204..8a67882 100644
--- a/stream/http.c
+++ b/stream/http.c
@@ -298,9 +298,8 @@ HTTP_header_t *
 http_new_header(void) {
 	HTTP_header_t *http_hdr;
 
-	http_hdr = malloc(sizeof(HTTP_header_t));
+	http_hdr = calloc(1, sizeof(*http_hdr));
 	if( http_hdr==NULL ) return NULL;
-	memset( http_hdr, 0, sizeof(HTTP_header_t) );
 
 	return http_hdr;
 }
diff --git a/stream/url.c b/stream/url.c
index 41fc633..5b1383c 100644
--- a/stream/url.c
+++ b/stream/url.c
@@ -102,15 +102,12 @@ url_new(const char* url) {
         }
 
 	// Create the URL container
-	Curl = malloc(sizeof(URL_t));
+	Curl = calloc(1, sizeof(*Curl));
 	if( Curl==NULL ) {
 		mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
 		goto err_out;
 	}
 
-	// Initialisation of the URL container members
-	memset( Curl, 0, sizeof(URL_t) );
-
 	url_escape_string(escfilename,url);
 
 	// Copy the url in the URL container
-- 
1.7.3.3


--gr/z0/N6AeWAPJVB--


More information about the MPlayer-dev-eng mailing list