aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/datagram.c14
-rw-r--r--src/stream.c8
2 files changed, 8 insertions, 14 deletions
diff --git a/src/datagram.c b/src/datagram.c
index cb2a64f..13f1b5c 100644
--- a/src/datagram.c
+++ b/src/datagram.c
@@ -39,7 +39,7 @@
struct osmo_dgram_tx {
struct osmo_fd ofd;
struct llist_head tx_queue;
- const char *addr;
+ char *addr;
uint16_t port;
char *local_addr;
uint16_t local_port;
@@ -125,10 +125,7 @@ void
osmo_dgram_tx_set_addr(struct osmo_dgram_tx *conn,
const char *addr)
{
- if (conn->addr != NULL)
- talloc_free((void *)conn->addr);
-
- conn->addr = talloc_strdup(conn, addr);
+ osmo_talloc_replace_string(conn, &conn->addr, addr);
conn->flags |= OSMO_DGRAM_CLI_F_RECONF;
}
@@ -224,7 +221,7 @@ void osmo_dgram_tx_send(struct osmo_dgram_tx *conn,
struct osmo_dgram_rx {
struct osmo_fd ofd;
- const char *addr;
+ char *addr;
uint16_t port;
int (*cb)(struct osmo_dgram_rx *conn);
void *data;
@@ -296,10 +293,7 @@ struct osmo_dgram_rx *osmo_dgram_rx_create(void *crx)
void osmo_dgram_rx_set_addr(struct osmo_dgram_rx *conn,
const char *addr)
{
- if (conn->addr != NULL)
- talloc_free((void *)conn->addr);
-
- conn->addr = talloc_strdup(conn, addr);
+ osmo_talloc_replace_string(conn, &conn->addr, addr);
conn->flags |= OSMO_DGRAM_RX_F_RECONF;
}
diff --git a/src/stream.c b/src/stream.c
index 52521d7..7bac1cc 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -81,7 +81,7 @@ struct osmo_stream_cli {
struct llist_head tx_queue;
struct osmo_timer_list timer;
enum osmo_stream_cli_state state;
- const char *addr;
+ char *addr;
uint16_t port;
char *local_addr;
uint16_t local_port;
@@ -264,7 +264,7 @@ struct osmo_stream_cli *osmo_stream_cli_create(void *ctx)
void
osmo_stream_cli_set_addr(struct osmo_stream_cli *cli, const char *addr)
{
- cli->addr = talloc_strdup(cli, addr);
+ osmo_talloc_replace_string(cli, &cli->addr, addr);
cli->flags |= OSMO_STREAM_CLI_F_RECONF;
}
@@ -474,7 +474,7 @@ int osmo_stream_cli_recv(struct osmo_stream_cli *cli, struct msgb *msg)
struct osmo_stream_srv_link {
struct osmo_fd ofd;
- const char *addr;
+ char *addr;
uint16_t port;
uint16_t proto;
int (*accept_cb)(struct osmo_stream_srv_link *srv, int fd);
@@ -537,7 +537,7 @@ struct osmo_stream_srv_link *osmo_stream_srv_link_create(void *ctx)
void osmo_stream_srv_link_set_addr(struct osmo_stream_srv_link *link,
const char *addr)
{
- link->addr = talloc_strdup(link, addr);
+ osmo_talloc_replace_string(link, &link->addr, addr);
link->flags |= OSMO_STREAM_SRV_F_RECONF;
}