From fc0bbf10795851f9fa804e3fff69ed6bea7e4d53 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 8 Jun 2021 08:26:06 -0400 Subject: [PATCH] TT#91151 switch str_init_dup to g_malloc This makes it possible to use buffers returned by GString interchangably. Change-Id: If15a5c0be2743dde7230b2f3d3ca6780d633622b --- daemon/call_interfaces.c | 4 ++-- daemon/main.c | 4 ++-- lib/str.h | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index f2bc39220..78eb14dcf 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -1236,8 +1236,8 @@ static void fragment_free(struct sdp_fragment *frag) { } static void fragment_key_free(void *p) { struct fragment_key *k = p; - free(k->call_id.s); - free(k->from_tag.s); + g_free(k->call_id.s); + g_free(k->from_tag.s); g_slice_free1(sizeof(*k), k); } static void queue_sdp_fragment(struct ng_buffer *ngbuf, GQueue *streams, struct sdp_ng_flags *flags) { diff --git a/daemon/main.c b/daemon/main.c index 2890cf237..495b16153 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -963,9 +963,9 @@ static void options_free(void) { g_free(rtpe_config.https_key); g_free(rtpe_config.software_id); if (rtpe_config.cn_payload.s) - free(rtpe_config.cn_payload.s); + g_free(rtpe_config.cn_payload.s); if (rtpe_config.dtx_cn_params.s) - free(rtpe_config.dtx_cn_params.s); + g_free(rtpe_config.dtx_cn_params.s); g_free(rtpe_config.mqtt_user); g_free(rtpe_config.mqtt_pass); g_free(rtpe_config.mqtt_cafile); diff --git a/lib/str.h b/lib/str.h index fe693d4ed..80b8ea249 100644 --- a/lib/str.h +++ b/lib/str.h @@ -233,7 +233,7 @@ INLINE str *str_init_len_assert_len(str *out, char *s, size_t buflen, size_t len return str_init_len(out, s, len); } INLINE str *str_init_dup(str *out, const char *s) { - out->s = s ? strdup(s) : NULL; + out->s = s ? g_strdup(s) : NULL; out->len = s ? strlen(s) : 0; return out; } @@ -242,7 +242,7 @@ INLINE str *str_init_dup_str(str *out, const str *s) { *out = STR_NULL; return out; } - char *buf = malloc(s->len + 1); + char *buf = g_malloc(s->len + 1); memcpy(buf, s->s, s->len); buf[s->len] = '\0'; out->len = s->len; @@ -254,7 +254,7 @@ INLINE void str_free_dup(str *out) { return; if (out->s) - free(out->s); + g_free(out->s); out->s = NULL; out->len = 0;