Browse code

usrloc: convert to memory logging helper

Henning Westerholt authored on 13/02/2020 21:28:44
Showing 5 changed files
... ...
@@ -556,7 +556,7 @@ static inline int new_dlist(str* _n, dlist_t** _d)
556 556
 	 */
557 557
 	ptr = (dlist_t*)shm_malloc(sizeof(dlist_t));
558 558
 	if (ptr == 0) {
559
-		LM_ERR("no more share memory\n");
559
+		SHM_MEM_ERROR;
560 560
 		return -1;
561 561
 	}
562 562
 	memset(ptr, 0, sizeof(dlist_t));
... ...
@@ -564,7 +564,7 @@ static inline int new_dlist(str* _n, dlist_t** _d)
564 564
 	/* copy domain name as null terminated string */
565 565
 	ptr->name.s = (char*)shm_malloc(_n->len+1);
566 566
 	if (ptr->name.s == 0) {
567
-		LM_ERR("no more memory left\n");
567
+		SHM_MEM_ERROR;
568 568
 		shm_free(ptr);
569 569
 		return -2;
570 570
 	}
... ...
@@ -95,7 +95,7 @@ ucontact_t* new_ucontact(str* _dom, str* _aor, str* _contact, ucontact_info_t* _
95 95
 
96 96
 	c = (ucontact_t*)shm_malloc(sizeof(ucontact_t));
97 97
 	if (!c) {
98
-		LM_ERR("no more shm memory\n");
98
+		SHM_MEM_ERROR;
99 99
 		return 0;
100 100
 	}
101 101
 	memset(c, 0, sizeof(ucontact_t));
... ...
@@ -138,7 +138,7 @@ ucontact_t* new_ucontact(str* _dom, str* _aor, str* _contact, ucontact_info_t* _
138 138
 
139 139
 	return c;
140 140
 error:
141
-	LM_ERR("no more shm memory\n");
141
+	SHM_MEM_ERROR;
142 142
 	if (c->path.s) shm_free(c->path.s);
143 143
 	if (c->received.s) shm_free(c->received.s);
144 144
 	if (c->user_agent.s) shm_free(c->user_agent.s);
... ...
@@ -245,7 +245,7 @@ int mem_update_ucontact(ucontact_t* _c, ucontact_info_t* _ci)
245 245
 		if ((_old)->len < (_new)->len) { \
246 246
 			ptr = (char*)shm_malloc((_new)->len); \
247 247
 			if (ptr == 0) { \
248
-				LM_ERR("no more shm memory\n"); \
248
+				SHM_MEM_ERROR; \
249 249
 				return -1; \
250 250
 			}\
251 251
 			memcpy(ptr, (_new)->s, (_new)->len);\
... ...
@@ -55,7 +55,7 @@ static char *build_stat_name( str* domain, char *var_name)
55 55
 	n = domain->len + 1 + strlen(var_name) + 1;
56 56
 	s = (char*)shm_malloc( n );
57 57
 	if (s==0) {
58
-		LM_ERR("no more shm mem\n");
58
+		SHM_MEM_ERROR;
59 59
 		return 0;
60 60
 	}
61 61
 	memcpy( s, domain->s, domain->len);
... ...
@@ -90,14 +90,14 @@ int new_udomain(str* _n, int _s, udomain_t** _d)
90 90
 	 */
91 91
 	*_d = (udomain_t*)shm_malloc(sizeof(udomain_t));
92 92
 	if (!(*_d)) {
93
-		LM_ERR("new_udomain(): No memory left\n");
93
+		SHM_MEM_ERROR;
94 94
 		goto error0;
95 95
 	}
96 96
 	memset(*_d, 0, sizeof(udomain_t));
97 97
 
98 98
 	(*_d)->table = (hslot_t*)shm_malloc(sizeof(hslot_t) * _s);
99 99
 	if (!(*_d)->table) {
100
-		LM_ERR("no memory left 2\n");
100
+		SHM_MEM_ERROR;
101 101
 		goto error1;
102 102
 	}
103 103
 
... ...
@@ -44,7 +44,7 @@ int init_ulcb_list(void)
44 44
 	ulcb_list = (struct ulcb_head_list*)shm_malloc
45 45
 		( sizeof(struct ulcb_head_list) );
46 46
 	if (ulcb_list==0) {
47
-		LM_CRIT("no more shared mem\n");
47
+		SHM_MEM_CRITICAL;
48 48
 		return -1;
49 49
 	}
50 50
 	ulcb_list->first = 0;
... ...
@@ -92,7 +92,7 @@ int register_ulcb( int types, ul_cb f, void *param )
92 92
 
93 93
 	/* build a new callback structure */
94 94
 	if (!(cbp=(struct ul_callback*)shm_malloc(sizeof( struct ul_callback)))) {
95
-		LM_ERR("no more share mem\n");
95
+		SHM_MEM_ERROR;
96 96
 		return E_OUT_OF_MEM;
97 97
 	}
98 98
 
... ...
@@ -57,14 +57,14 @@ int new_urecord(str* _dom, str* _aor, urecord_t** _r)
57 57
 {
58 58
 	*_r = (urecord_t*)shm_malloc(sizeof(urecord_t));
59 59
 	if (*_r == 0) {
60
-		LM_ERR("no more share memory\n");
60
+		SHM_MEM_ERROR;
61 61
 		return -1;
62 62
 	}
63 63
 	memset(*_r, 0, sizeof(urecord_t));
64 64
 
65 65
 	(*_r)->aor.s = (char*)shm_malloc(_aor->len);
66 66
 	if ((*_r)->aor.s == 0) {
67
-		LM_ERR("no more share memory\n");
67
+		SHM_MEM_ERROR;
68 68
 		shm_free(*_r);
69 69
 		*_r = 0;
70 70
 		return -2;