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.
diff --git a/openbsc/src/bsc/osmo_bsc_vty.c b/openbsc/src/bsc/osmo_bsc_vty.c
index ac366ab..d5c018b 100644
--- a/openbsc/src/bsc/osmo_bsc_vty.c
+++ b/openbsc/src/bsc/osmo_bsc_vty.c
@@ -72,10 +72,7 @@
 {
 	struct osmo_msc_data *data = osmo_msc_data(vty);
 
-	if (data->bsc_token)
-		talloc_free(data->bsc_token);
-	data->bsc_token = talloc_strdup(data, argv[0]);
-
+	bsc_replace_string(data, &data->bsc_token, argv[0]);
 	return CMD_SUCCESS;
 }
 
@@ -84,10 +81,8 @@
       "ip A.B.C.D", "Set the MSC/MUX IP address.")
 {
 	struct osmo_msc_data *data = osmo_msc_data(vty);
-	if (data->msc_ip)
-		talloc_free(data->msc_ip);
-	data->msc_ip = talloc_strdup(data, argv[0]);
 
+	bsc_replace_string(data, &data->msc_ip, argv[0]);
 	return CMD_SUCCESS;
 }
 
@@ -142,9 +137,7 @@
 	if (!txt)
 		return CMD_WARNING;
 
-	if (data->ussd_grace_txt)
-		talloc_free(data->ussd_grace_txt);
-	data->ussd_grace_txt = talloc_strdup(data, txt);
+	bsc_replace_string(data, &data->ussd_grace_txt, txt);
 	talloc_free(txt);
 	return CMD_SUCCESS;
 }