Ver Fonte

- use log helper from mem.h for memory allocation failure logging

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@5153 689a6050-402a-0410-94f2-e92a70836424
Henning Westerholt há 17 anos atrás
pai
commit
a083345f11

+ 3 - 3
modules/carrierroute/cr_config.c

@@ -112,7 +112,7 @@ static int backup_config(void) {
 	char * backup_file, ch;
 	LM_INFO("start configuration backup\n");
 	if((backup_file = pkg_malloc(strlen(config_file) + strlen (".bak") + 1)) == NULL){
-		LM_ERR("out of private memory\n");
+		PKG_MEM_ERROR;
 		return -1;
 	}
 	if(!strcpy(backup_file, config_file)){
@@ -193,7 +193,7 @@ int load_config(struct route_data_t * rd) {
 	}
 
 	if ((rd->carriers = shm_malloc(sizeof(struct carrier_data_t *))) == NULL) {
-		LM_ERR("out of shared memory\n");
+		SHM_MEM_ERROR;
 		return -1;
 	}
 	memset(rd->carriers, 0, sizeof(struct carrier_data_t *));
@@ -254,7 +254,7 @@ int load_config(struct route_data_t * rd) {
 
 				if ((backed_up_size = cfg_size(t, "backed_up")) > 0) {
 					if ((backed_up = pkg_malloc(sizeof(int) * (backed_up_size + 1))) == NULL) {
-						LM_ERR("out of private memory\n");
+						PKG_MEM_ERROR;
 						return -1;
 					}
 					for (l = 0; l < backed_up_size; l++) {

+ 3 - 3
modules/carrierroute/cr_db.c

@@ -164,7 +164,7 @@ int load_route_data_db(struct route_data_t * rd) {
 	}
 
 	if ((rd->carriers = shm_malloc(sizeof(struct carrier_data_t *) * carrier_count)) == NULL) {
-		LM_ERR("out of shared memory\n");
+		SHM_MEM_ERROR;
 		goto errout;
 	}
 	memset(rd->carriers, 0, sizeof(struct carrier_data_t *) * carrier_count);
@@ -355,12 +355,12 @@ static int store_carriers(struct carrier ** start){
 	count = RES_ROW_N(res);
 	for(i=0; i<RES_ROW_N(res); i++){
 		if((nc = pkg_malloc(sizeof(struct carrier))) == NULL){
-			LM_ERR("out of private memory\n");
+			PKG_MEM_ERROR;
 			return -1;
 		}
 		nc->id = res->rows[i].values[0].val.int_val;
 		if((nc->name = pkg_malloc(strlen(res->rows[i].values[1].val.string_val) + 1)) == NULL){
-			LM_ERR("out of private memory\n");
+			PKG_MEM_ERROR;
 			pkg_free(nc);
 			goto errout;
 		}

+ 1 - 1
modules/carrierroute/cr_fifo.c

@@ -746,7 +746,7 @@ static int update_route_data_recursor(struct dtrie_node_t *node, str * act_domai
 						}
 						if (opts->new_host.len) {
 							if ((rr->host.s = shm_malloc(opts->new_host.len + 1)) == NULL) {
-								LM_ERR("out of shared mem\n");
+								SHM_MEM_ERROR;
 								FIFO_ERR(E_NOMEM);
 								return -1;
 							}

+ 1 - 1
modules/carrierroute/cr_func.c

@@ -294,7 +294,7 @@ static int actually_rewrite(const struct route_rule *rs, str *dest,
 	dest->len = 0;
 	dest->s = (char *)pkg_malloc(len + 1);
 	if (dest->s == NULL) {
-		LM_ERR("out of private memory.\n");
+		PKG_MEM_ERROR;
 		return -1;
 	}
 	dest->len = len;

+ 6 - 6
modules/carrierroute/cr_rule.c

@@ -72,7 +72,7 @@ int add_route_rule(struct route_flags *rf, const str * prefix,
 	}
 
 	if ((shm_rr = shm_malloc(sizeof(struct route_rule))) == NULL) {
-		LM_ERR("out of shared memory\n");
+		SHM_MEM_ERROR;
 		return -1;
 	}
 	memset(shm_rr, 0, sizeof(struct route_rule));
@@ -152,7 +152,7 @@ int add_route_rule(struct route_flags *rf, const str * prefix,
 	return 0;
 
 mem_error:
-	LM_ERR("out of shared memory\n");
+	SHM_MEM_ERROR;
 	destroy_route_rule(shm_rr);
 	return -1;
 }
@@ -223,7 +223,7 @@ struct route_flags * add_route_flags(struct route_flags **rf_head, const flag_t
 	}
 
 	if ((shm_rf = shm_malloc(sizeof(struct route_flags))) == NULL) {
-		LM_ERR("out of shared memory\n");
+		SHM_MEM_ERROR;
 		return NULL;
 	}
 	memset(shm_rf, 0, sizeof(struct route_flags));
@@ -343,7 +343,7 @@ struct failure_route_rule *add_failure_route_rule(struct failure_route_rule **fr
 	frr = prev = NULL;
 	
 	if ((shm_frr = shm_malloc(sizeof(struct failure_route_rule))) == NULL) {
-		LM_ERR("out of shared memory\n");
+		SHM_MEM_ERROR;
 		return NULL;
 	}
 	memset(shm_frr, 0, sizeof(struct failure_route_rule));
@@ -448,7 +448,7 @@ int add_backup_rule(struct route_rule * rule, struct route_rule * backup){
 		return -1;
 	}
 	if((tmp = shm_malloc(sizeof(struct route_rule_p_list))) == NULL) {
-		LM_ERR("out of shared memory\n");
+		SHM_MEM_ERROR;
 		return -1;
 	}
 	memset(tmp, 0, sizeof(struct route_rule_p_list));
@@ -459,7 +459,7 @@ int add_backup_rule(struct route_rule * rule, struct route_rule * backup){
 
 	tmp = NULL;
 	if((tmp = shm_malloc(sizeof(struct route_rule_p_list))) == NULL) {
-		LM_ERR("out of shared memory\n");
+		SHM_MEM_ERROR;
 		return -1;
 	}
 	memset(tmp, 0, sizeof(struct route_rule_p_list));