[MPlayer-dev-eng] [PATCH 5/7] Use MSGTR_MemAllocFailed instead of hardcoded string

Clément Bœsch ubitux at gmail.com
Mon Oct 18 12:05:55 CEST 2010


Subject should be self explanatory.
---
 stream/http.c |   32 ++++++++++++++++----------------
 1 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/stream/http.c b/stream/http.c
index c5f1b12..67ce1e8 100644
--- a/stream/http.c
+++ b/stream/http.c
@@ -335,7 +335,7 @@ http_response_append( HTTP_header_t *http_hdr, char *response, int length ) {
 	}
 	http_hdr->buffer = realloc( http_hdr->buffer, http_hdr->buffer_size+length+1 );
 	if( http_hdr->buffer==NULL ) {
-		mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory (re)allocation failed\n");
+		mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
 		return -1;
 	}
 	memcpy( http_hdr->buffer+http_hdr->buffer_size, response, length );
@@ -372,7 +372,7 @@ http_response_parse( HTTP_header_t *http_hdr ) {
 	len = hdr_ptr-http_hdr->buffer;
 	http_hdr->protocol = malloc(len+1);
 	if( http_hdr->protocol==NULL ) {
-		mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed\n");
+		mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
 		return -1;
 	}
 	strncpy( http_hdr->protocol, http_hdr->buffer, len );
@@ -400,7 +400,7 @@ http_response_parse( HTTP_header_t *http_hdr ) {
 	len = ptr-hdr_ptr;
 	http_hdr->reason_phrase = malloc(len+1);
 	if( http_hdr->reason_phrase==NULL ) {
-		mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed\n");
+		mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
 		return -1;
 	}
 	strncpy( http_hdr->reason_phrase, hdr_ptr, len );
@@ -431,7 +431,7 @@ http_response_parse( HTTP_header_t *http_hdr ) {
 		if( len==0 ) break;
 		field = realloc(field, len+1);
 		if( field==NULL ) {
-			mp_msg(MSGT_NETWORK,MSGL_ERR,"Memory allocation failed\n");
+			mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MemAllocFailed);
 			return -1;
 		}
 		strncpy( field, hdr_ptr, len );
@@ -464,7 +464,7 @@ http_build_request( HTTP_header_t *http_hdr ) {
 	else {
 		uri = malloc(strlen(http_hdr->uri) + 1);
 		if( uri==NULL ) {
-			mp_msg(MSGT_NETWORK,MSGL_ERR,"Memory allocation failed\n");
+			mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MemAllocFailed);
 			return NULL;
 		}
 		strcpy(uri,http_hdr->uri);
@@ -492,7 +492,7 @@ http_build_request( HTTP_header_t *http_hdr ) {
 	}
 	http_hdr->buffer = malloc(len+1);
 	if( http_hdr->buffer==NULL ) {
-		mp_msg(MSGT_NETWORK,MSGL_ERR,"Memory allocation failed\n");
+		mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MemAllocFailed);
 		return NULL;
 	}
 	http_hdr->buffer_size = len;
@@ -523,7 +523,7 @@ http_get_field( HTTP_header_t *http_hdr, const char *field_name ) {
 	http_hdr->field_search_pos = http_hdr->first_field;
 	http_hdr->field_search = realloc( http_hdr->field_search, strlen(field_name)+1 );
 	if( http_hdr->field_search==NULL ) {
-		mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed\n");
+		mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
 		return NULL;
 	}
 	strcpy( http_hdr->field_search, field_name );
@@ -558,13 +558,13 @@ http_set_field( HTTP_header_t *http_hdr, const char *field_name ) {
 
 	new_field = malloc(sizeof(HTTP_field_t));
 	if( new_field==NULL ) {
-		mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed\n");
+		mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
 		return;
 	}
 	new_field->next = NULL;
 	new_field->field_name = malloc(strlen(field_name)+1);
 	if( new_field->field_name==NULL ) {
-		mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed\n");
+		mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
 		free(new_field);
 		return;
 	}
@@ -585,7 +585,7 @@ http_set_method( HTTP_header_t *http_hdr, const char *method ) {
 
 	http_hdr->method = malloc(strlen(method)+1);
 	if( http_hdr->method==NULL ) {
-		mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed\n");
+		mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
 		return;
 	}
 	strcpy( http_hdr->method, method );
@@ -597,7 +597,7 @@ http_set_uri( HTTP_header_t *http_hdr, const char *uri ) {
 
 	http_hdr->uri = malloc(strlen(uri)+1);
 	if( http_hdr->uri==NULL ) {
-		mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed\n");
+		mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
 		return;
 	}
 	strcpy( http_hdr->uri, uri );
@@ -614,7 +614,7 @@ http_add_authentication( HTTP_header_t *http_hdr, const char *username, const ch
 
 	username_decoded = malloc(strlen(username) + 1);
 	if (username_decoded == NULL) {
-		mp_msg(MSGT_NETWORK, MSGL_FATAL, "Memory allocation failed\n");
+		mp_msg(MSGT_NETWORK, MSGL_FATAL, MSGTR_MemAllocFailed);
 		goto out;
 	}
 	url_unescape_string(username_decoded, username);
@@ -623,7 +623,7 @@ http_add_authentication( HTTP_header_t *http_hdr, const char *username, const ch
 	if( password!=NULL ) {
 		password_decoded = malloc(strlen(password) + 1);
 		if (password_decoded == NULL) {
-			mp_msg(MSGT_NETWORK, MSGL_FATAL, "Memory allocation failed\n");
+			mp_msg(MSGT_NETWORK, MSGL_FATAL, MSGTR_MemAllocFailed);
 			goto out;
 		}
 		url_unescape_string(password_decoded, password);
@@ -633,7 +633,7 @@ http_add_authentication( HTTP_header_t *http_hdr, const char *username, const ch
 
 	usr_pass = malloc(strlen(username)+pass_len+2);
 	if( usr_pass==NULL ) {
-		mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed\n");
+		mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
 		goto out;
 	}
 
@@ -643,7 +643,7 @@ http_add_authentication( HTTP_header_t *http_hdr, const char *username, const ch
 	encoded_len = strlen(usr_pass)*2;
 	b64_usr_pass = malloc(encoded_len);
 	if( b64_usr_pass==NULL ) {
-		mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed\n");
+		mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
 		goto out;
 	}
 
@@ -657,7 +657,7 @@ http_add_authentication( HTTP_header_t *http_hdr, const char *username, const ch
 
 	auth = malloc(encoded_len + strlen(auth_str) + 1);
 	if( auth==NULL ) {
-		mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed\n");
+		mp_msg(MSGT_NETWORK,MSGL_FATAL,MSGTR_MemAllocFailed);
 		goto out;
 	}
 
-- 
1.7.3.1



More information about the MPlayer-dev-eng mailing list