TT#91151 switch str_init_dup to g_malloc

This makes it possible to use buffers returned by GString
interchangably.

Change-Id: If15a5c0be2743dde7230b2f3d3ca6780d633622b
pull/1295/head
Richard Fuchs 5 years ago
parent 72bb874cc5
commit fc0bbf1079

@ -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) {

@ -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);

@ -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;

Loading…
Cancel
Save