diff --git a/daemon/call.c b/daemon/call.c index f7e487ac2..6657c77aa 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -2761,9 +2761,8 @@ static void __call_monologue_init_from_flags(struct call_monologue *ml, struct c /* consume sdp session parts */ { /* origin (name, version etc.) */ - if (flags->session_sdp_orig.parsed) { - ml->sdp_orig_in = sdp_orig_dup(&flags->session_sdp_orig); - } + if (flags->session_sdp_orig.parsed) + sdp_orig_dup(&ml->sdp_orig_in, &flags->session_sdp_orig); /* sdp session name */ if (flags->session_sdp_name.len && @@ -5462,6 +5461,8 @@ void __monologue_free(struct call_monologue *m) { t_queue_clear_full(&m->all_attributes, sdp_attr_free); t_queue_clear(&m->tag_aliases); t_queue_clear(&m->groups_other); + sdp_orig_free(&m->sdp_orig_in); + sdp_orig_free(&m->sdp_orig_out); memory_arena_free_lw(m); } diff --git a/daemon/redis.c b/daemon/redis.c index 8a49d5d69..5cae27380 100644 --- a/daemon/redis.c +++ b/daemon/redis.c @@ -1605,30 +1605,30 @@ static void redis_decode_monologue_sdp(struct call_monologue *ml, const struct r ml->sdp_orig_in.parsed = 1; redis_hash_get_llu(&ml->sdp_orig_in.version_num, rh, "sdp_orig_version_num"); if (!redis_hash_get_str(&s, rh, "sdp_orig_username")) - ml->sdp_orig_in.username = call_str_cpy(&s); + memory_arena_str_cpy_free(&ml->sdp_orig_in.username, &s); if (!redis_hash_get_str(&s, rh, "sdp_orig_session_id")) - ml->sdp_orig_in.session_id = call_str_cpy(&s); + memory_arena_str_cpy_free(&ml->sdp_orig_in.session_id, &s); if (!redis_hash_get_str(&s, rh, "sdp_orig_address_network_type")) - ml->sdp_orig_in.address.network_type = call_str_cpy(&s); + memory_arena_str_cpy_free(&ml->sdp_orig_in.address.network_type, &s); if (!redis_hash_get_str(&s, rh, "sdp_orig_address_address_type")) - ml->sdp_orig_in.address.address_type = call_str_cpy(&s); + memory_arena_str_cpy_free(&ml->sdp_orig_in.address.address_type, &s); if (!redis_hash_get_str(&s, rh, "sdp_orig_address_address")) - ml->sdp_orig_in.address.address = call_str_cpy(&s); + memory_arena_str_cpy_free(&ml->sdp_orig_in.address.address, &s); } /* o= last used of the other side*/ if (!redis_hash_get_str(&s, rh, "last_sdp_orig_parsed")) { ml->sdp_orig_out.parsed = 1; redis_hash_get_llu(&ml->sdp_orig_out.version_num, rh, "last_sdp_orig_version_num"); if (!redis_hash_get_str(&s, rh, "last_sdp_orig_username")) - ml->sdp_orig_out.username = call_str_cpy(&s); + memory_arena_str_cpy_free(&ml->sdp_orig_out.username, &s); if (!redis_hash_get_str(&s, rh, "last_sdp_orig_session_id")) - ml->sdp_orig_out.session_id = call_str_cpy(&s); + memory_arena_str_cpy_free(&ml->sdp_orig_out.session_id, &s); if (!redis_hash_get_str(&s, rh, "last_sdp_orig_address_network_type")) - ml->sdp_orig_out.address.network_type = call_str_cpy(&s); + memory_arena_str_cpy_free(&ml->sdp_orig_out.address.network_type, &s); if (!redis_hash_get_str(&s, rh, "last_sdp_orig_address_address_type")) - ml->sdp_orig_out.address.address_type = call_str_cpy(&s); + memory_arena_str_cpy_free(&ml->sdp_orig_out.address.address_type, &s); if (!redis_hash_get_str(&s, rh, "last_sdp_orig_address_address")) - ml->sdp_orig_out.address.address = call_str_cpy(&s); + memory_arena_str_cpy_free(&ml->sdp_orig_out.address.address, &s); } ml->sdp_session_bandwidth.as = (!redis_hash_get_ld(&il, rh, "sdp_session_as")) ? il : -1; diff --git a/daemon/sdp.c b/daemon/sdp.c index 96010986a..ec65128a0 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -1914,20 +1914,25 @@ void sdp_attr_free(struct sdp_attr *c) { g_free(c); } -sdp_origin sdp_orig_dup(const sdp_origin *orig) { - sdp_origin copy = {}; - copy.username = call_str_cpy(&orig->username); - copy.session_id = call_str_cpy(&orig->session_id); - copy.version_num = orig->version_num; - copy.version_output_pos = orig->version_output_pos; - copy.parsed = orig->parsed; +void sdp_orig_dup(sdp_origin *copy, const sdp_origin *orig) { + memory_arena_str_cpy_free(©->username, &orig->username); + memory_arena_str_cpy_free(©->session_id, &orig->session_id); + copy->version_num = orig->version_num; + copy->version_output_pos = orig->version_output_pos; + copy->parsed = orig->parsed; /* struct network_address */ - copy.address.network_type = call_str_cpy(&orig->address.network_type); - copy.address.address_type = call_str_cpy(&orig->address.address_type); - copy.address.address = call_str_cpy(&orig->address.address); - copy.address.parsed = orig->address.parsed; + memory_arena_str_cpy_free(©->address.network_type, &orig->address.network_type); + memory_arena_str_cpy_free(©->address.address_type, &orig->address.address_type); + memory_arena_str_cpy_free(©->address.address, &orig->address.address); + copy->address.parsed = orig->address.parsed; +} - return copy; +void sdp_orig_free(sdp_origin *orig) { + memory_arena_free_lw(orig->username.s); + memory_arena_free_lw(orig->session_id.s); + memory_arena_free_lw(orig->address.network_type.s); + memory_arena_free_lw(orig->address.address_type.s); + memory_arena_free_lw(orig->address.address.s); } static void sdp_attr_append1(sdp_attr_q *dst, const struct sdp_attribute *attr) { @@ -3058,7 +3063,7 @@ static void sdp_out_add_origin(GString *out, struct call_monologue *monologue, orig_address = STR(sockaddr_print_buf(&first_ps->selected_sfd->local_intf->advertised_address.addr)); } - monologue->sdp_orig_out = sdp_orig_dup(&(sdp_origin) { + sdp_orig_dup(&monologue->sdp_orig_out, &(sdp_origin) { .username = username, .session_id = session_id, .version_num = session_version, diff --git a/include/call.h b/include/call.h index b2d6fecff..753482b2c 100644 --- a/include/call.h +++ b/include/call.h @@ -1041,8 +1041,6 @@ G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(call_q, call_q_unlock_release); #include "str.h" #include "rtp.h" -#define call_malloc memory_arena_alloc - #define call_strdup memory_arena_strdup #define call_strdup_str memory_arena_strdup_str #define call_str_cpy_len memory_arena_str_cpy_len diff --git a/include/sdp.h b/include/sdp.h index cc9323a85..ffe96d04a 100644 --- a/include/sdp.h +++ b/include/sdp.h @@ -41,7 +41,8 @@ void append_v_str_attr_to_gstring(GString *s, const str *name, const sdp_ng_flag #define sdp_append_attr(s, g, t, n, f, ...) append_v_str_attr_to_gstring(s, STR_PTR(n), g, t, f, ##__VA_ARGS__) void sdp_attr_free(struct sdp_attr *); -sdp_origin sdp_orig_dup(const sdp_origin *orig); +void sdp_orig_dup(sdp_origin *copy, const sdp_origin *orig); +void sdp_orig_free(sdp_origin *); bool sdp_parse(str *body, sdp_sessions_q *sessions, const sdp_ng_flags *); bool sdp_streams(const sdp_sessions_q *sessions, sdp_streams_q *streams, sdp_ng_flags *);