diff options
author | Harald Welte <laforge@gnumonks.org> | 2017-04-08 22:09:57 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2017-04-10 06:47:28 +0000 |
commit | 0bacc71fc208e5cdf0727de027438b8e901ff666 (patch) | |
tree | c67d11c94438a8fcd147392ea4dcb16e96fad458 /src/stream.c | |
parent | a2c2b59165ebb63ccca0838922501b717d5233a7 (diff) |
stream/datagram: Consistently use osmo_talloc_replace_string()
during osmo_*_set_addr(), we must make sure to talloc_free() any old
address before copying in the new address. Not all functions did this,
and those that did implemented it manually. Let's use
osmo_talloc_replace_string() which is exactly intended for this case.
Change-Id: Ie1b140a160c66e8b62c745174865d5ba525cb2c2
Diffstat (limited to 'src/stream.c')
-rw-r--r-- | src/stream.c | 8 |
1 files changed, 4 insertions, 4 deletions
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; } |