diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-10-12 21:31:02 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-10-25 21:04:46 +0200 |
commit | 64b12924bfacaacda4eb5657ab6348a86db48753 (patch) | |
tree | f87fccb27afe50dd63f530980c686fc1db1d9d48 /openbsc | |
parent | e393f273e7c65edea09b12385ca648724c9c3825 (diff) |
nat: 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')
-rw-r--r-- | openbsc/src/nat/bsc_nat_vty.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/openbsc/src/nat/bsc_nat_vty.c b/openbsc/src/nat/bsc_nat_vty.c index b284fedd5..9eb8ebc75 100644 --- a/openbsc/src/nat/bsc_nat_vty.c +++ b/openbsc/src/nat/bsc_nat_vty.c @@ -409,9 +409,7 @@ DEFUN(cfg_nat_ussd_lst_name, "Set the name of the access list to check for IMSIs for USSD message\n" "The name of the access list for HLR USSD handling") { - if (_nat->ussd_lst_name) - talloc_free(_nat->ussd_lst_name); - _nat->ussd_lst_name = talloc_strdup(_nat, argv[0]); + bsc_replace_string(_nat, &_nat->ussd_lst_name, argv[0]); return CMD_SUCCESS; } @@ -421,9 +419,7 @@ DEFUN(cfg_nat_ussd_query, "Set the USSD query to match with the ussd-list-name\n" "The query to match") { - if (_nat->ussd_query) - talloc_free(_nat->ussd_query); - _nat->ussd_query = talloc_strdup(_nat, argv[0]); + bsc_replace_string(_nat, &_nat->ussd_query, argv[0]); return CMD_SUCCESS; } @@ -432,9 +428,7 @@ DEFUN(cfg_nat_ussd_token, "ussd-token TOKEN", "Set the token used to identify the USSD module\n" "Secret key\n") { - if (_nat->ussd_token) - talloc_free(_nat->ussd_token); - _nat->ussd_token = talloc_strdup(_nat, argv[0]); + bsc_replace_string(_nat, &_nat->ussd_token, argv[0]); return CMD_SUCCESS; } @@ -443,9 +437,7 @@ DEFUN(cfg_nat_ussd_local, "ussd-local-ip A.B.C.D", "Set the IP to listen for the USSD Provider\n" "IP Address\n") { - if (_nat->ussd_local) - talloc_free(_nat->ussd_local); - _nat->ussd_local = talloc_strdup(_nat, argv[0]); + bsc_replace_string(_nat, &_nat->ussd_local, argv[0]); return CMD_SUCCESS; } |