aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/mgcp/mgcp_vty.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-10-12 23:21:54 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-10-12 23:31:53 +0200
commit3e9a7f80bd6b1d62d3c3b175382ff15fa2f106c7 (patch)
treedaebaa0f94f1d7a22cfa0dbcccb9a4409f65a3c9 /openbsc/src/mgcp/mgcp_vty.c
parent9ecf678995145d7a49c440beb755627f03ff719c (diff)
misc: Replace the idiom for replacing a string with a function call
Remove a lot of code in favor of a new function that is freeing the old string and copying the new one. I should have gotten the context and the strings right.
Diffstat (limited to 'openbsc/src/mgcp/mgcp_vty.c')
-rw-r--r--openbsc/src/mgcp/mgcp_vty.c24
1 files changed, 6 insertions, 18 deletions
diff --git a/openbsc/src/mgcp/mgcp_vty.c b/openbsc/src/mgcp/mgcp_vty.c
index a9845a12f..d78b8c78a 100644
--- a/openbsc/src/mgcp/mgcp_vty.c
+++ b/openbsc/src/mgcp/mgcp_vty.c
@@ -127,9 +127,7 @@ DEFUN(cfg_mgcp_local_ip,
"local ip A.B.C.D",
"Set the IP to be used in SDP records")
{
- if (g_cfg->local_ip)
- talloc_free(g_cfg->local_ip);
- g_cfg->local_ip = talloc_strdup(g_cfg, argv[0]);
+ bsc_replace_string(g_cfg, &g_cfg->local_ip, argv[0]);
return CMD_SUCCESS;
}
@@ -138,9 +136,7 @@ DEFUN(cfg_mgcp_bts_ip,
"bts ip A.B.C.D",
"Set the IP of the BTS for RTP forwarding")
{
- if (g_cfg->bts_ip)
- talloc_free(g_cfg->bts_ip);
- g_cfg->bts_ip = talloc_strdup(g_cfg, argv[0]);
+ bsc_replace_string(g_cfg, &g_cfg->bts_ip, argv[0]);
inet_aton(g_cfg->bts_ip, &g_cfg->bts_in);
return CMD_SUCCESS;
}
@@ -150,9 +146,7 @@ DEFUN(cfg_mgcp_bind_ip,
"bind ip A.B.C.D",
"Bind the MGCP to this local addr")
{
- if (g_cfg->source_addr)
- talloc_free(g_cfg->source_addr);
- g_cfg->source_addr = talloc_strdup(g_cfg, argv[0]);
+ bsc_replace_string(g_cfg, &g_cfg->source_addr, argv[0]);
return CMD_SUCCESS;
}
@@ -281,9 +275,7 @@ DEFUN(cfg_mgcp_sdp_payload_name,
"sdp audio payload name NAME",
"Set the audio name to use")
{
- if (g_cfg->audio_name)
- talloc_free(g_cfg->audio_name);
- g_cfg->audio_name = talloc_strdup(g_cfg, argv[0]);
+ bsc_replace_string(g_cfg, &g_cfg->audio_name, argv[0]);
return CMD_SUCCESS;
}
@@ -311,9 +303,7 @@ DEFUN(cfg_mgcp_agent_addr,
"call agent ip IP",
"Set the address of the call agent.")
{
- if (g_cfg->call_agent_addr)
- talloc_free(g_cfg->call_agent_addr);
- g_cfg->call_agent_addr = talloc_strdup(g_cfg, argv[0]);
+ bsc_replace_string(g_cfg, &g_cfg->call_agent_addr, argv[0]);
return CMD_SUCCESS;
}
@@ -323,9 +313,7 @@ DEFUN(cfg_mgcp_transcoder,
"Use a MGW to detranscoder RTP\n"
"The IP address of the MGW")
{
- if (g_cfg->transcoder_ip)
- talloc_free(g_cfg->transcoder_ip);
- g_cfg->transcoder_ip = talloc_strdup(g_cfg, argv[0]);
+ bsc_replace_string(g_cfg, &g_cfg->transcoder_ip, argv[0]);
inet_aton(g_cfg->transcoder_ip, &g_cfg->transcoder_in);
return CMD_SUCCESS;