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.
This commit is contained in:
Holger Hans Peter Freyther 2010-10-12 21:31:02 +02:00
parent e393f273e7
commit 64b12924bf
1 changed files with 4 additions and 12 deletions

View File

@ -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" "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") "The name of the access list for HLR USSD handling")
{ {
if (_nat->ussd_lst_name) bsc_replace_string(_nat, &_nat->ussd_lst_name, argv[0]);
talloc_free(_nat->ussd_lst_name);
_nat->ussd_lst_name = talloc_strdup(_nat, argv[0]);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -421,9 +419,7 @@ DEFUN(cfg_nat_ussd_query,
"Set the USSD query to match with the ussd-list-name\n" "Set the USSD query to match with the ussd-list-name\n"
"The query to match") "The query to match")
{ {
if (_nat->ussd_query) bsc_replace_string(_nat, &_nat->ussd_query, argv[0]);
talloc_free(_nat->ussd_query);
_nat->ussd_query = talloc_strdup(_nat, argv[0]);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -432,9 +428,7 @@ DEFUN(cfg_nat_ussd_token,
"ussd-token TOKEN", "ussd-token TOKEN",
"Set the token used to identify the USSD module\n" "Secret key\n") "Set the token used to identify the USSD module\n" "Secret key\n")
{ {
if (_nat->ussd_token) bsc_replace_string(_nat, &_nat->ussd_token, argv[0]);
talloc_free(_nat->ussd_token);
_nat->ussd_token = talloc_strdup(_nat, argv[0]);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -443,9 +437,7 @@ DEFUN(cfg_nat_ussd_local,
"ussd-local-ip A.B.C.D", "ussd-local-ip A.B.C.D",
"Set the IP to listen for the USSD Provider\n" "IP Address\n") "Set the IP to listen for the USSD Provider\n" "IP Address\n")
{ {
if (_nat->ussd_local) bsc_replace_string(_nat, &_nat->ussd_local, argv[0]);
talloc_free(_nat->ussd_local);
_nat->ussd_local = talloc_strdup(_nat, argv[0]);
return CMD_SUCCESS; return CMD_SUCCESS;
} }