Browse code

- 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 authored on 03/11/2008 09:45:28
Showing 5 changed files
... ...
@@ -112,7 +112,7 @@ static int backup_config(void) {
112 112
 	char * backup_file, ch;
113 113
 	LM_INFO("start configuration backup\n");
114 114
 	if((backup_file = pkg_malloc(strlen(config_file) + strlen (".bak") + 1)) == NULL){
115
-		LM_ERR("out of private memory\n");
115
+		PKG_MEM_ERROR;
116 116
 		return -1;
117 117
 	}
118 118
 	if(!strcpy(backup_file, config_file)){
... ...
@@ -193,7 +193,7 @@ int load_config(struct route_data_t * rd) {
193 193
 	}
194 194
 
195 195
 	if ((rd->carriers = shm_malloc(sizeof(struct carrier_data_t *))) == NULL) {
196
-		LM_ERR("out of shared memory\n");
196
+		SHM_MEM_ERROR;
197 197
 		return -1;
198 198
 	}
199 199
 	memset(rd->carriers, 0, sizeof(struct carrier_data_t *));
... ...
@@ -254,7 +254,7 @@ int load_config(struct route_data_t * rd) {
254 254
 
255 255
 				if ((backed_up_size = cfg_size(t, "backed_up")) > 0) {
256 256
 					if ((backed_up = pkg_malloc(sizeof(int) * (backed_up_size + 1))) == NULL) {
257
-						LM_ERR("out of private memory\n");
257
+						PKG_MEM_ERROR;
258 258
 						return -1;
259 259
 					}
260 260
 					for (l = 0; l < backed_up_size; l++) {
... ...
@@ -164,7 +164,7 @@ int load_route_data_db(struct route_data_t * rd) {
164 164
 	}
165 165
 
166 166
 	if ((rd->carriers = shm_malloc(sizeof(struct carrier_data_t *) * carrier_count)) == NULL) {
167
-		LM_ERR("out of shared memory\n");
167
+		SHM_MEM_ERROR;
168 168
 		goto errout;
169 169
 	}
170 170
 	memset(rd->carriers, 0, sizeof(struct carrier_data_t *) * carrier_count);
... ...
@@ -355,12 +355,12 @@ static int store_carriers(struct carrier ** start){
355 355
 	count = RES_ROW_N(res);
356 356
 	for(i=0; i<RES_ROW_N(res); i++){
357 357
 		if((nc = pkg_malloc(sizeof(struct carrier))) == NULL){
358
-			LM_ERR("out of private memory\n");
358
+			PKG_MEM_ERROR;
359 359
 			return -1;
360 360
 		}
361 361
 		nc->id = res->rows[i].values[0].val.int_val;
362 362
 		if((nc->name = pkg_malloc(strlen(res->rows[i].values[1].val.string_val) + 1)) == NULL){
363
-			LM_ERR("out of private memory\n");
363
+			PKG_MEM_ERROR;
364 364
 			pkg_free(nc);
365 365
 			goto errout;
366 366
 		}
... ...
@@ -746,7 +746,7 @@ static int update_route_data_recursor(struct dtrie_node_t *node, str * act_domai
746 746
 						}
747 747
 						if (opts->new_host.len) {
748 748
 							if ((rr->host.s = shm_malloc(opts->new_host.len + 1)) == NULL) {
749
-								LM_ERR("out of shared mem\n");
749
+								SHM_MEM_ERROR;
750 750
 								FIFO_ERR(E_NOMEM);
751 751
 								return -1;
752 752
 							}
... ...
@@ -294,7 +294,7 @@ static int actually_rewrite(const struct route_rule *rs, str *dest,
294 294
 	dest->len = 0;
295 295
 	dest->s = (char *)pkg_malloc(len + 1);
296 296
 	if (dest->s == NULL) {
297
-		LM_ERR("out of private memory.\n");
297
+		PKG_MEM_ERROR;
298 298
 		return -1;
299 299
 	}
300 300
 	dest->len = len;
... ...
@@ -72,7 +72,7 @@ int add_route_rule(struct route_flags *rf, const str * prefix,
72 72
 	}
73 73
 
74 74
 	if ((shm_rr = shm_malloc(sizeof(struct route_rule))) == NULL) {
75
-		LM_ERR("out of shared memory\n");
75
+		SHM_MEM_ERROR;
76 76
 		return -1;
77 77
 	}
78 78
 	memset(shm_rr, 0, sizeof(struct route_rule));
... ...
@@ -152,7 +152,7 @@ int add_route_rule(struct route_flags *rf, const str * prefix,
152 152
 	return 0;
153 153
 
154 154
 mem_error:
155
-	LM_ERR("out of shared memory\n");
155
+	SHM_MEM_ERROR;
156 156
 	destroy_route_rule(shm_rr);
157 157
 	return -1;
158 158
 }
... ...
@@ -223,7 +223,7 @@ struct route_flags * add_route_flags(struct route_flags **rf_head, const flag_t
223 223
 	}
224 224
 
225 225
 	if ((shm_rf = shm_malloc(sizeof(struct route_flags))) == NULL) {
226
-		LM_ERR("out of shared memory\n");
226
+		SHM_MEM_ERROR;
227 227
 		return NULL;
228 228
 	}
229 229
 	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
343 343
 	frr = prev = NULL;
344 344
 	
345 345
 	if ((shm_frr = shm_malloc(sizeof(struct failure_route_rule))) == NULL) {
346
-		LM_ERR("out of shared memory\n");
346
+		SHM_MEM_ERROR;
347 347
 		return NULL;
348 348
 	}
349 349
 	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){
448 448
 		return -1;
449 449
 	}
450 450
 	if((tmp = shm_malloc(sizeof(struct route_rule_p_list))) == NULL) {
451
-		LM_ERR("out of shared memory\n");
451
+		SHM_MEM_ERROR;
452 452
 		return -1;
453 453
 	}
454 454
 	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){
459 459
 
460 460
 	tmp = NULL;
461 461
 	if((tmp = shm_malloc(sizeof(struct route_rule_p_list))) == NULL) {
462
-		LM_ERR("out of shared memory\n");
462
+		SHM_MEM_ERROR;
463 463
 		return -1;
464 464
 	}
465 465
 	memset(tmp, 0, sizeof(struct route_rule_p_list));