Browse Source

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
commit
fc0bbf1079
3 changed files with 7 additions and 7 deletions
  1. +2
    -2
      daemon/call_interfaces.c
  2. +2
    -2
      daemon/main.c
  3. +3
    -3
      lib/str.h

+ 2
- 2
daemon/call_interfaces.c View File

@ -1236,8 +1236,8 @@ static void fragment_free(struct sdp_fragment *frag) {
} }
static void fragment_key_free(void *p) { static void fragment_key_free(void *p) {
struct fragment_key *k = 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); g_slice_free1(sizeof(*k), k);
} }
static void queue_sdp_fragment(struct ng_buffer *ngbuf, GQueue *streams, struct sdp_ng_flags *flags) { static void queue_sdp_fragment(struct ng_buffer *ngbuf, GQueue *streams, struct sdp_ng_flags *flags) {


+ 2
- 2
daemon/main.c View File

@ -963,9 +963,9 @@ static void options_free(void) {
g_free(rtpe_config.https_key); g_free(rtpe_config.https_key);
g_free(rtpe_config.software_id); g_free(rtpe_config.software_id);
if (rtpe_config.cn_payload.s) 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) 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_user);
g_free(rtpe_config.mqtt_pass); g_free(rtpe_config.mqtt_pass);
g_free(rtpe_config.mqtt_cafile); g_free(rtpe_config.mqtt_cafile);


+ 3
- 3
lib/str.h View File

@ -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); return str_init_len(out, s, len);
} }
INLINE str *str_init_dup(str *out, const char *s) { 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; out->len = s ? strlen(s) : 0;
return out; return out;
} }
@ -242,7 +242,7 @@ INLINE str *str_init_dup_str(str *out, const str *s) {
*out = STR_NULL; *out = STR_NULL;
return out; return out;
} }
char *buf = malloc(s->len + 1);
char *buf = g_malloc(s->len + 1);
memcpy(buf, s->s, s->len); memcpy(buf, s->s, s->len);
buf[s->len] = '\0'; buf[s->len] = '\0';
out->len = s->len; out->len = s->len;
@ -254,7 +254,7 @@ INLINE void str_free_dup(str *out) {
return; return;
if (out->s) if (out->s)
free(out->s);
g_free(out->s);
out->s = NULL; out->s = NULL;
out->len = 0; out->len = 0;


Loading…
Cancel
Save