Module: kamailio
Branch: master
Commit: f427ac803b8d2b33970da5071ecb9f9db5c25499
URL:
https://github.com/kamailio/kamailio/commit/f427ac803b8d2b33970da5071ecb9f9…
Author: Henning Westerholt <hw(a)skalatan.de>
Committer: Henning Westerholt <hw(a)skalatan.de>
Date: 2019-11-23T23:01:28+01:00
jsonrpcc: use core string handling instead of redundant implementation
---
Modified: src/modules/jsonrpcc/jsonrpc_request.c
---
Diff:
https://github.com/kamailio/kamailio/commit/f427ac803b8d2b33970da5071ecb9f9…
Patch:
https://github.com/kamailio/kamailio/commit/f427ac803b8d2b33970da5071ecb9f9…
---
diff --git a/src/modules/jsonrpcc/jsonrpc_request.c
b/src/modules/jsonrpcc/jsonrpc_request.c
index 9032bddaaf..d2321e5f37 100644
--- a/src/modules/jsonrpcc/jsonrpc_request.c
+++ b/src/modules/jsonrpcc/jsonrpc_request.c
@@ -30,7 +30,6 @@
struct tm_binds tmb;
-static char *shm_strdup(str *src);
int memory_error() {
LM_ERR("Out of memory!");
@@ -100,10 +99,10 @@ int jsonrpc_request(struct sip_msg* _m, char* _method, char* _params,
char* _cb_
cb_pv = memcpy(cb_pv, (pv_spec_t *)_cb_pv, sizeof(pv_spec_t));
- cmd->method = shm_strdup(&method);
- cmd->params = shm_strdup(¶ms);
- cmd->cb_route = shm_strdup(&cb_route);
- cmd->err_route = shm_strdup(&err_route);
+ cmd->method = shm_str2char_dup(&method);
+ cmd->params = shm_str2char_dup(¶ms);
+ cmd->cb_route = shm_str2char_dup(&cb_route);
+ cmd->err_route = shm_str2char_dup(&err_route);
cmd->cb_pv = cb_pv;
cmd->msg = _m;
cmd->t_hash = hash_index;
@@ -137,8 +136,8 @@ int jsonrpc_notification(struct sip_msg* _m, char* _method, char*
_params)
memset(cmd, 0, sizeof(struct jsonrpc_pipe_cmd));
- cmd->method = shm_strdup(&method);
- cmd->params = shm_strdup(¶ms);
+ cmd->method = shm_str2char_dup(&method);
+ cmd->params = shm_str2char_dup(¶ms);
cmd->notify_only = 1;
if (write(cmd_pipe, &cmd, sizeof(cmd)) != sizeof(cmd)) {
@@ -148,16 +147,3 @@ int jsonrpc_notification(struct sip_msg* _m, char* _method, char*
_params)
return 1;
}
-
-static char *shm_strdup(str *src)
-{
- char *res;
-
- if (!src || !src->s)
- return NULL;
- if (!(res = (char *) shm_malloc(src->len + 1)))
- return NULL;
- strncpy(res, src->s, src->len);
- res[src->len] = 0;
- return res;
-}