Browse code

uac: convert to memory logging helper

Henning Westerholt authored on 13/02/2020 21:45:36
Showing 5 changed files
... ...
@@ -59,7 +59,7 @@ static struct uac_credential *crd_list = 0;
59 59
 		_strd.s = (char*)pkg_malloc(_strs.len); \
60 60
 		if (_strd.s==0) \
61 61
 		{ \
62
-			LM_ERR("no more pkg memory\n");\
62
+			PKG_MEM_ERROR;\
63 63
 			goto _error; \
64 64
 		} \
65 65
 		memcpy( _strd.s, _strs.s, _strs.len); \
... ...
@@ -112,7 +112,7 @@ int add_credential( unsigned int type, void *val)
112 112
 	crd = (struct uac_credential*)pkg_malloc(sizeof(struct uac_credential));
113 113
 	if (crd==0)
114 114
 	{
115
-		LM_ERR("no more pkg mem\n");
115
+		PKG_MEM_ERROR;
116 116
 		goto error;
117 117
 	}
118 118
 	memset( crd, 0, sizeof(struct uac_credential));
... ...
@@ -341,7 +341,7 @@ static inline int apply_urihdr_changes( struct sip_msg *req,
341 341
 	req->new_uri.s = (char*)pkg_malloc(uri->len+1);
342 342
 	if (req->new_uri.s==0)
343 343
 	{
344
-		LM_ERR("no more pkg\n");
344
+		PKG_MEM_ERROR;
345 345
 		goto error;
346 346
 	}
347 347
 	memcpy( req->new_uri.s, uri->s, uri->len);
... ...
@@ -340,7 +340,7 @@ str* build_authorization_hdr(int code, str *uri,
340 340
 	_uac_auth_hdr.s = (char*)pkg_malloc( len + 1);
341 341
 	if (_uac_auth_hdr.s==0)
342 342
 	{
343
-		LM_ERR("no more pkg mem\n");
343
+		PKG_MEM_ERROR;
344 344
 		goto error;
345 345
 	}
346 346
 
... ...
@@ -217,7 +217,7 @@ static inline struct lump* get_display_anchor(struct sip_msg *msg,
217 217
 	}
218 218
 	p1 = (char*)pkg_malloc(1);
219 219
 	if (p1==0) {
220
-		LM_ERR("no more pkg mem \n");
220
+		PKG_MEM_ERROR;
221 221
 		return 0;
222 222
 	}
223 223
 	*p1 = '>';
... ...
@@ -333,7 +333,7 @@ int replace_uri( struct sip_msg *msg, str *display, str *uri,
333 333
 			buf.s = pkg_malloc( display->len + 2 );
334 334
 			if (buf.s==0)
335 335
 			{
336
-				LM_ERR("no more pkg mem\n");
336
+				PKG_MEM_ERROR;
337 337
 				goto error;
338 338
 			}
339 339
 			memcpy( buf.s, display->s, display->len);
... ...
@@ -370,7 +370,7 @@ int replace_uri( struct sip_msg *msg, str *display, str *uri,
370 370
 	p = pkg_malloc( uri->len);
371 371
 	if (p==0)
372 372
 	{
373
-		LM_ERR("no more pkg mem\n");
373
+		PKG_MEM_ERROR;
374 374
 		goto error;
375 375
 	}
376 376
 	memcpy( p, uri->s, uri->len);
... ...
@@ -510,7 +510,7 @@ int replace_uri( struct sip_msg *msg, str *display, str *uri,
510 510
 		param.s = (char*)pkg_malloc(param.len);
511 511
 		if (param.s==0)
512 512
 		{
513
-			LM_ERR("no more pkg mem\n");
513
+			PKG_MEM_ERROR;
514 514
 			goto error;
515 515
 		}
516 516
 		p = param.s;
... ...
@@ -594,7 +594,7 @@ int restore_uri( struct sip_msg *msg, str *rr_param, str* restore_avp,
594 594
 	add_to_rr.s = pkg_malloc(bsize);
595 595
 	if ( add_to_rr.s==0 ) {
596 596
 		add_to_rr.len = 0;
597
-		LM_ERR("no more pkg mem\n");
597
+		PKG_MEM_ERROR;
598 598
 		goto failed;
599 599
 	}
600 600
 	add_to_rr.len = snprintf(add_to_rr.s, bsize, ";%.*s=%.*s",
... ...
@@ -696,7 +696,7 @@ int restore_uri( struct sip_msg *msg, str *rr_param, str* restore_avp,
696 696
 	/* duplicate the decoded value */
697 697
 	p = pkg_malloc( new_uri.len);
698 698
 	if (p==0) {
699
-		LM_ERR("no more pkg mem\n");
699
+		PKG_MEM_ERROR;
700 700
 		goto failed;
701 701
 	}
702 702
 	memcpy( p, new_uri.s, new_uri.len);
... ...
@@ -776,7 +776,7 @@ static inline int restore_uri_reply(struct sip_msg *rpl,
776 776
 
777 777
 	new_val.s = pkg_malloc( len );
778 778
 	if (new_val.s==0) {
779
-		LM_ERR("no more pkg mem\n");
779
+		PKG_MEM_ERROR;
780 780
 		return -1;
781 781
 	}
782 782
 	memcpy( new_val.s, p, len);
... ...
@@ -945,7 +945,7 @@ static void replace_callback(struct dlg_cell *dlg, int type,
945 945
 	/* duplicate the decoded value */
946 946
 	p = pkg_malloc( new_uri->len);
947 947
 	if (!p) {
948
-		LM_ERR("no more pkg mem\n");
948
+		PKG_MEM_ERROR;
949 949
 		return;
950 950
 	}
951 951
 	memcpy( p, new_uri->s, new_uri->len);
... ...
@@ -981,7 +981,7 @@ static void replace_callback(struct dlg_cell *dlg, int type,
981 981
 		/* add the new display exactly over the deleted one */
982 982
 		buf.s = pkg_malloc(new_display->len + 2);
983 983
 		if (buf.s==0) {
984
-			LM_ERR("no more pkg mem\n");
984
+			PKG_MEM_ERROR;
985 985
 			goto free;
986 986
 		}
987 987
 		memcpy( buf.s, new_display->s, new_display->len);
... ...
@@ -163,7 +163,7 @@ int reg_active_init(int mode)
163 163
 	}
164 164
 	reg_active = (int*)shm_malloc(sizeof(int));
165 165
 	if(reg_active==NULL) {
166
-		LM_ERR("not enough shared memory\n");
166
+		SHM_MEM_ERROR;
167 167
 		return -1;
168 168
 	}
169 169
 	*reg_active = mode;
... ...
@@ -190,7 +190,7 @@ int uac_reg_init_ht(unsigned int sz)
190 190
 	_reg_htable_gc_lock = (gen_lock_t*)shm_malloc(sizeof(gen_lock_t));
191 191
 	if(_reg_htable_gc_lock == NULL)
192 192
 	{
193
-		LM_ERR("no more shm for lock\n");
193
+		SHM_MEM_ERROR;
194 194
 		return -1;
195 195
 	}
196 196
 	if(lock_init(_reg_htable_gc_lock)==0)
... ...
@@ -202,7 +202,7 @@ int uac_reg_init_ht(unsigned int sz)
202 202
 	_reg_htable_gc = (reg_ht_t*)shm_malloc(sizeof(reg_ht_t));
203 203
 	if(_reg_htable_gc==NULL)
204 204
 	{
205
-		LM_ERR("no more shm\n");
205
+		SHM_MEM_ERROR;
206 206
 		lock_destroy(_reg_htable_gc_lock);
207 207
 		shm_free((void*)_reg_htable_gc_lock);
208 208
 		return -1;
... ...
@@ -214,7 +214,7 @@ int uac_reg_init_ht(unsigned int sz)
214 214
 		(reg_entry_t*)shm_malloc(_reg_htable_gc->htsize*sizeof(reg_entry_t));
215 215
 	if(_reg_htable_gc->entries==NULL)
216 216
 	{
217
-		LM_ERR("no more shm.\n");
217
+		SHM_MEM_ERROR;
218 218
 		shm_free(_reg_htable_gc);
219 219
 		lock_destroy(_reg_htable_gc_lock);
220 220
 		shm_free((void*)_reg_htable_gc_lock);
... ...
@@ -226,7 +226,7 @@ int uac_reg_init_ht(unsigned int sz)
226 226
 	_reg_htable = (reg_ht_t*)shm_malloc(sizeof(reg_ht_t));
227 227
 	if(_reg_htable==NULL)
228 228
 	{
229
-		LM_ERR("no more shm\n");
229
+		SHM_MEM_ERROR;
230 230
 		shm_free(_reg_htable_gc->entries);
231 231
 		shm_free(_reg_htable_gc);
232 232
 		lock_destroy(_reg_htable_gc_lock);
... ...
@@ -240,7 +240,7 @@ int uac_reg_init_ht(unsigned int sz)
240 240
 		(reg_entry_t*)shm_malloc(_reg_htable->htsize*sizeof(reg_entry_t));
241 241
 	if(_reg_htable->entries==NULL)
242 242
 	{
243
-		LM_ERR("no more shm.\n");
243
+		SHM_MEM_ERROR;
244 244
 		shm_free(_reg_htable_gc->entries);
245 245
 		shm_free(_reg_htable_gc);
246 246
 		shm_free(_reg_htable);
... ...
@@ -452,7 +452,7 @@ int reg_ht_add_byuuid(reg_uac_t *reg)
452 452
 	ri = (reg_item_t*)shm_malloc(sizeof(reg_item_t));
453 453
 	if(ri==NULL)
454 454
 	{
455
-		LM_ERR("no more shm\n");
455
+		SHM_MEM_ERROR;
456 456
 		return -1;
457 457
 	}
458 458
 	memset(ri, 0, sizeof(reg_item_t));
... ...
@@ -483,7 +483,7 @@ int reg_ht_add_byuser(reg_uac_t *reg)
483 483
 	ri = (reg_item_t*)shm_malloc(sizeof(reg_item_t));
484 484
 	if(ri==NULL)
485 485
 	{
486
-		LM_ERR("no more shm\n");
486
+		SHM_MEM_ERROR;
487 487
 		return -1;
488 488
 	}
489 489
 	memset(ri, 0, sizeof(reg_item_t));
... ...
@@ -537,7 +537,7 @@ int reg_ht_add(reg_uac_t *reg)
537 537
 	nr = (reg_uac_t*)shm_malloc(sizeof(reg_uac_t) + len);
538 538
 	if(nr==NULL)
539 539
 	{
540
-		LM_ERR("no more shm\n");
540
+		SHM_MEM_ERROR;
541 541
 		return -1;
542 542
 	}
543 543
 	memset(nr, 0, sizeof(reg_uac_t) + len);
... ...
@@ -1096,7 +1096,7 @@ int uac_reg_update(reg_uac_t *reg, time_t tn)
1096 1096
 	uuid = (char*)shm_malloc(reg->l_uuid.len+1);
1097 1097
 	if(uuid==NULL)
1098 1098
 	{
1099
-		LM_ERR("no more shm\n");
1099
+		SHM_MEM_ERROR;
1100 1100
 		return -1;
1101 1101
 	}
1102 1102
 	reg->timer_expires = tn;
... ...
@@ -105,7 +105,7 @@ uac_send_info_t *uac_send_info_clone(uac_send_info_t *ur)
105 105
 	tp = (uac_send_info_t*)shm_malloc(sizeof(uac_send_info_t));
106 106
 	if(tp==NULL)
107 107
 	{
108
-		LM_ERR("no more shm memory\n");
108
+		SHM_MEM_ERROR;
109 109
 		return NULL;
110 110
 	}
111 111
 	uac_send_info_copy(ur, tp);