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_vty.c b/openbsc/src/bsc_vty.c
index 97641f2..488ecc7 100644
--- a/openbsc/src/bsc_vty.c
+++ b/openbsc/src/bsc_vty.c
@@ -1062,11 +1062,7 @@
{
struct gsm_network *gsmnet = gsmnet_from_vty(vty);
- if (gsmnet->name_short)
- talloc_free(gsmnet->name_short);
-
- gsmnet->name_short = talloc_strdup(gsmnet, argv[0]);
-
+ bsc_replace_string(gsmnet, &gsmnet->name_short, argv[0]);
return CMD_SUCCESS;
}
@@ -1077,11 +1073,7 @@
{
struct gsm_network *gsmnet = gsmnet_from_vty(vty);
- if (gsmnet->name_long)
- talloc_free(gsmnet->name_long);
-
- gsmnet->name_long = talloc_strdup(gsmnet, argv[0]);
-
+ bsc_replace_string(gsmnet, &gsmnet->name_long, argv[0]);
return CMD_SUCCESS;
}