aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/nat/bsc_nat_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/nat/bsc_nat_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/nat/bsc_nat_vty.c')
-rw-r--r--openbsc/src/nat/bsc_nat_vty.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/openbsc/src/nat/bsc_nat_vty.c b/openbsc/src/nat/bsc_nat_vty.c
index 1dbc75569..9822e5c57 100644
--- a/openbsc/src/nat/bsc_nat_vty.c
+++ b/openbsc/src/nat/bsc_nat_vty.c
@@ -368,9 +368,7 @@ DEFUN(cfg_nat_token, cfg_nat_token_cmd,
"token TOKEN",
"Set a token for the NAT")
{
- if (_nat->token)
- talloc_free(_nat->token);
- _nat->token = talloc_strdup(_nat, argv[0]);
+ bsc_replace_string(_nat, &_nat->token, argv[0]);
return CMD_SUCCESS;
}
@@ -393,9 +391,7 @@ DEFUN(cfg_nat_acc_lst_name,
"Set the name of the access list to use.\n"
"The name of the to be used access list.")
{
- if (_nat->acc_lst_name)
- talloc_free(_nat->acc_lst_name);
- _nat->acc_lst_name = talloc_strdup(_nat, argv[0]);
+ bsc_replace_string(_nat, &_nat->acc_lst_name, argv[0]);
return CMD_SUCCESS;
}
@@ -428,9 +424,7 @@ DEFUN(cfg_bsc_token, cfg_bsc_token_cmd, "token TOKEN", "Set the token")
{
struct bsc_config *conf = vty->index;
- if (conf->token)
- talloc_free(conf->token);
- conf->token = talloc_strdup(conf, argv[0]);
+ bsc_replace_string(conf, &conf->token, argv[0]);
return CMD_SUCCESS;
}
@@ -559,9 +553,7 @@ DEFUN(cfg_bsc_acc_lst_name,
{
struct bsc_config *conf = vty->index;
- if (conf->acc_lst_name)
- talloc_free(conf->acc_lst_name);
- conf->acc_lst_name = talloc_strdup(conf, argv[0]);
+ bsc_replace_string(conf, &conf->acc_lst_name, argv[0]);
return CMD_SUCCESS;
}
@@ -587,9 +579,7 @@ DEFUN(cfg_bsc_desc,
{
struct bsc_config *conf = vty->index;
- if (conf->description)
- talloc_free(conf->description);
- conf->description = talloc_strdup(conf, argv[0]);
+ bsc_replace_string(conf, &conf->description, argv[0]);
return CMD_SUCCESS;
}