浏览代码

tmx: convert to memory logging helper

Henning Westerholt 5 年之前
父节点
当前提交
e1f1b3a5e5
共有 2 个文件被更改,包括 9 次插入7 次删除
  1. 6 4
      src/modules/tmx/t_var.c
  2. 3 3
      src/modules/tmx/tmx_pretran.c

+ 6 - 4
src/modules/tmx/t_var.c

@@ -117,7 +117,7 @@ int pv_t_update_req(struct sip_msg *msg)
 		_pv_treq.buf = (char*)pkg_malloc(_pv_treq.buf_size*sizeof(char));
 		if(_pv_treq.buf==NULL)
 		{
-			LM_ERR("no more pkg\n");
+			PKG_MEM_ERROR;
 			_pv_treq.buf_size = 0;
 			return -1;
 		}
@@ -195,7 +195,7 @@ int pv_t_update_rpl(struct sip_msg *msg)
 		_pv_trpl.buf = (char*)pkg_malloc(_pv_trpl.buf_size*sizeof(char));
 		if(_pv_trpl.buf==NULL)
 		{
-			LM_ERR("no more pkg\n");
+			PKG_MEM_ERROR;
 			_pv_trpl.buf_size = 0;
 			return -1;
 		}
@@ -263,7 +263,7 @@ int pv_t_update_inv(struct sip_msg *msg)
 		_pv_tinv.buf = (char*)pkg_malloc(_pv_tinv.buf_size*sizeof(char));
 		if(_pv_tinv.buf==NULL)
 		{
-			LM_ERR("no more pkg\n");
+			PKG_MEM_ERROR;
 			_pv_tinv.buf_size = 0;
 			goto error;
 		}
@@ -368,8 +368,10 @@ int pv_parse_t_var_name(pv_spec_p sp, str *in)
 		return -1;
 
 	pv = (pv_spec_t*)pkg_malloc(sizeof(pv_spec_t));
-	if(pv==NULL)
+	if(pv==NULL) {
+		PKG_MEM_ERROR;
 		return -1;
+	}
 
 	memset(pv, 0, sizeof(pv_spec_t));
 

+ 3 - 3
src/modules/tmx/tmx_pretran.c

@@ -89,7 +89,7 @@ int tmx_init_pretran_table(void)
 
 	_tmx_ptran_table = (pretran_slot_t*)shm_malloc(_tmx_ptran_size*sizeof(pretran_slot_t));
 	if(_tmx_ptran_table == NULL) {
-		LM_ERR("not enough shared memory\n");
+		SHM_MEM_ERROR;
 		return -1;
 	}
 	memset(_tmx_ptran_table, 0, _tmx_ptran_size*sizeof(pretran_slot_t));
@@ -249,7 +249,7 @@ int tmx_check_pretran(sip_msg_t *msg)
 	if(unlikely(_tmx_proc_ptran == NULL)) {
 		_tmx_proc_ptran = (pretran_t*)shm_malloc(sizeof(pretran_t));
 		if(_tmx_proc_ptran == NULL) {
-			LM_ERR("not enough memory for pretran structure\n");
+			SHM_MEM_ERROR_FMT("pretran structure\n");
 			return -1;
 		}
 		memset(_tmx_proc_ptran, 0, sizeof(pretran_t));
@@ -270,7 +270,7 @@ int tmx_check_pretran(sip_msg_t *msg)
 		if(_tmx_proc_ptran->dbuf.s) shm_free(_tmx_proc_ptran->dbuf.s);
 		_tmx_proc_ptran->dbuf.s = (char*)shm_malloc(dsize);
 		if(_tmx_proc_ptran->dbuf.s==NULL) {
-			LM_ERR("not enough memory for pretran data\n");
+			SHM_MEM_ERROR_FMT("pretran data\n");
 			return -1;
 		}
 		_tmx_proc_ptran->dbuf.len = dsize;