MT#55283 remove remnants of g_slice

The GLib slice allocator has been obsoleted. Having a mixture of two
allocators can lead to hidden issues on systems that use different
implementations. Take the leap and replace everything with g_new/g_free.

Change-Id: I025c8383ef47b2c2472573360407fd6a6ca339b3
mr13.3
Richard Fuchs 8 months ago
parent fa3de35448
commit 4d8156bf91

@ -103,7 +103,7 @@ bool audio_player_setup(struct call_media *m, const rtp_payload_type *dst_pt,
ZERO(ap->mb);
}
else
ap = m->audio_player = g_slice_alloc0(sizeof(*m->audio_player));
ap = m->audio_player = g_new0(__typeof(*m->audio_player), 1);
if (mp)
media_player_stop(mp);
@ -216,7 +216,7 @@ void audio_player_free(struct call_media *m) {
return;
mix_buffer_destroy(&ap->mb);
media_player_put(&ap->mp);
g_slice_free1(sizeof(*ap), ap);
g_free(ap);
m->audio_player = NULL;
}

@ -429,7 +429,7 @@ fault:
_exit(1);
}
g_slice_free1(sizeof(*xh), xh);
g_free(xh);
}
void kill_calls_timer(GSList *list, const char *url) {
@ -444,7 +444,7 @@ void kill_calls_timer(GSList *list, const char *url) {
/* if url is NULL, it's the scheduled deletions, otherwise it's the timeouts */
if (url) {
xh = g_slice_alloc(sizeof(*xh));
xh = g_new(__typeof(*xh), 1);
url_prefix = NULL;
url_suffix = strstr(url, "%%");
if (url_suffix) {
@ -875,7 +875,7 @@ static struct endpoint_map *__get_endpoint_map(struct call_media *media, unsigne
if (il->list.length != num_ports)
goto next_il;
struct sfd_intf_list *em_il = g_slice_alloc0(sizeof(*em_il));
struct sfd_intf_list *em_il = g_new0(__typeof(*em_il), 1);
em_il->local_intf = il->local_intf;
t_queue_push_tail(&em->intf_sfds, em_il);
@ -1246,7 +1246,7 @@ void __rtp_stats_update(rtp_stats_ht dst, struct codec_store *cs) {
}
void free_sink_handler(struct sink_handler *sh) {
g_slice_free1(sizeof(*sh), sh);
g_free(sh);
}
/**
@ -1254,7 +1254,7 @@ void free_sink_handler(struct sink_handler *sh) {
* using the __streams_set_sinks() through __add_sink_handler().
*/
void __add_sink_handler(sink_handler_q *q, struct packet_stream *sink, const struct sink_attrs *attrs) {
struct sink_handler *sh = g_slice_alloc0(sizeof(*sh));
struct sink_handler *sh = g_new0(__typeof(*sh), 1);
sh->sink = sink;
sh->kernel_output_idx = -1;
if (attrs)
@ -1729,7 +1729,7 @@ static void __generate_crypto(const sdp_ng_flags *flags, struct call_media *this
continue;
}
struct crypto_params_sdes *cps = g_slice_alloc0(sizeof(*cps));
struct crypto_params_sdes *cps = g_new0(__typeof(*cps), 1);
t_queue_push_tail(cpq, cps);
cps->tag = offered_cps->tag;
@ -1783,7 +1783,7 @@ static void __generate_crypto(const sdp_ng_flags *flags, struct call_media *this
continue;
}
struct crypto_params_sdes *cps = g_slice_alloc0(sizeof(*cps));
struct crypto_params_sdes *cps = g_new0(__typeof(*cps), 1);
t_queue_push_tail(cpq, cps);
cps->tag = c_tag++;
@ -1888,7 +1888,7 @@ static void __generate_crypto(const sdp_ng_flags *flags, struct call_media *this
cps_match:
if (cps_in && (!cps || cps->params.crypto_suite != cps_in->params.crypto_suite)) {
crypto_params_sdes_queue_clear(cpq);
cps = g_slice_alloc0(sizeof(*cps));
cps = g_new0(__typeof(*cps), 1);
t_queue_push_tail(cpq, cps);
cps->tag = cps_in->tag;
@ -3315,8 +3315,8 @@ static void __unsubscribe_media_link(struct call_media * which, subscription_lis
t_hash_table_remove(which->media_subscriptions_ht, ms->media);
t_hash_table_remove(from->media_subscribers_ht, rev_ms->media);
g_slice_free1(sizeof(*ms), ms);
g_slice_free1(sizeof(*rev_ms), rev_ms);
g_free(ms);
g_free(rev_ms);
}
/**
* Unsubscribe one particular media subscriber from this call media.
@ -3421,8 +3421,8 @@ struct media_subscription *__add_media_subscription(struct call_media * which, s
STR_FMT_M(&which->monologue->tag), which->index,
STR_FMT_M(&to->monologue->tag), to->index);
struct media_subscription *which_ms = g_slice_alloc0(sizeof(*which_ms));
struct media_subscription *to_rev_ms = g_slice_alloc0(sizeof(*to_rev_ms));
struct media_subscription *which_ms = g_new0(__typeof(*which_ms), 1);
struct media_subscription *to_rev_ms = g_new0(__typeof(*to_rev_ms), 1);
which_ms->media = to;
to_rev_ms->media = which;
@ -4279,7 +4279,7 @@ int call_stream_address(GString *s, struct packet_stream *ps, enum stream_addres
}
void media_subscription_free(struct media_subscription *p) {
g_slice_free1(sizeof(*p), p);
g_free(p);
}
void call_media_free(struct call_media **mdp) {

@ -278,7 +278,7 @@ static bool streams_parse_func(char **a, void **ret, void *p) {
int *i;
i = p;
sp = g_slice_alloc0(sizeof(*sp));
sp = g_new0(__typeof(*sp), 1);
SP_SET(sp, SEND);
SP_SET(sp, RECV);
@ -301,7 +301,7 @@ static bool streams_parse_func(char **a, void **ret, void *p) {
fail:
ilog(LOG_WARNING, "Failed to parse a media stream: %s%s:%s%s", FMT_M(a[0], a[1]));
g_slice_free1(sizeof(*sp), sp);
g_free(sp);
return false;
}
@ -2379,7 +2379,7 @@ static void ng_sdp_attr_manipulations_free(struct sdp_manipulations * array[__MT
str_case_value_ht_destroy_ptr(&sdp_manipulations->subst_commands);
t_queue_clear_full(&sdp_manipulations->add_commands, str_free);
g_slice_free1(sizeof(*sdp_manipulations), sdp_manipulations);
g_free(sdp_manipulations);
array[i] = NULL;
}
@ -3376,7 +3376,7 @@ static const char *media_block_match(call_t **call, struct call_monologue **mono
return NULL;
}
void add_media_to_sub_list(subscription_q *q, struct call_media *media, struct call_monologue *ml) {
struct media_subscription *ms = g_slice_alloc0(sizeof(*ms));
struct media_subscription *ms = g_new0(__typeof(*ms), 1);
ms->media = media;
ms->monologue = ml;
t_queue_push_tail(q, ms);

@ -451,7 +451,7 @@ static void __codec_handler_free(struct codec_handler *h) {
__handler_shutdown(h);
payload_type_clear(&h->source_pt);
payload_type_clear(&h->dest_pt);
g_slice_free1(sizeof(*h), h);
g_free(h);
}
void codec_handler_free(struct codec_handler **handler) {
if (!handler || !*handler)
@ -463,7 +463,7 @@ void codec_handler_free(struct codec_handler **handler) {
static struct codec_handler *__handler_new(const rtp_payload_type *pt, struct call_media *media,
struct call_media *sink)
{
struct codec_handler *handler = g_slice_alloc0(sizeof(*handler));
struct codec_handler *handler = g_new0(__typeof(*handler), 1);
handler->source_pt.payload_type = -1;
if (pt)
rtp_payload_type_copy(&handler->source_pt, pt);
@ -2072,14 +2072,14 @@ static void codec_add_raw_packet_common(struct media_packet *mp, unsigned int cl
t_queue_push_tail(&mp->packets_out, p);
}
void codec_add_raw_packet(struct media_packet *mp, unsigned int clockrate) {
struct codec_packet *p = g_slice_alloc0(sizeof(*p));
struct codec_packet *p = g_new0(__typeof(*p), 1);
p->s = mp->raw;
p->free_func = NULL;
codec_add_raw_packet_common(mp, clockrate, p);
}
#ifdef WITH_TRANSCODING
static void codec_add_raw_packet_dup(struct media_packet *mp, unsigned int clockrate) {
struct codec_packet *p = g_slice_alloc0(sizeof(*p));
struct codec_packet *p = g_new0(__typeof(*p), 1);
// don't just duplicate the string. need to ensure enough room
// if encryption is enabled on this stream
p->s.s = bufferpool_alloc(media_bufferpool, mp->raw.len + RTP_BUFFER_TAIL_ROOM);
@ -2172,7 +2172,7 @@ static void __ssrc_unlock_both(struct media_packet *mp) {
static void __seq_free(void *p) {
packet_sequencer_t *seq = p;
packet_sequencer_destroy(seq);
g_slice_free1(sizeof(*seq), seq);
g_free(seq);
}
static int __handler_func_sequencer(struct media_packet *mp, struct transcode_packet *packet)
@ -2235,7 +2235,7 @@ static int __handler_func_sequencer(struct media_packet *mp, struct transcode_pa
ssrc_in_p->sequencers = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, __seq_free);
packet_sequencer_t *seq = g_hash_table_lookup(ssrc_in_p->sequencers, mp->media_out);
if (!seq) {
seq = g_slice_alloc0(sizeof(*seq));
seq = g_new0(__typeof(*seq), 1);
packet_sequencer_init(seq, (GDestroyNotify) __transcode_packet_free);
g_hash_table_insert(ssrc_in_p->sequencers, mp->media_out, seq);
// this is a quick fix to restore sequencer values until upper layer behavior will be fixed
@ -2394,7 +2394,7 @@ void codec_output_rtp(struct media_packet *mp, struct codec_scheduler *csch,
rh->ssrc = htonl(ssrc_out_p->h.ssrc);
// add to output queue
struct codec_packet *p = g_slice_alloc0(sizeof(*p));
struct codec_packet *p = g_new0(__typeof(*p), 1);
p->s.s = buf;
p->s.len = payload_len + sizeof(struct rtp_header);
payload_tracker_add(&ssrc_out->tracker, handler->dest_pt.payload_type);
@ -2676,7 +2676,7 @@ static tc_code packet_dtmf(struct codec_ssrc_handler *ch, struct codec_ssrc_hand
r.timestamp = htonl(ts);
for (; copies > 0; copies--) {
struct transcode_packet *dup = g_slice_alloc(sizeof(*dup));
struct transcode_packet *dup = g_new(__typeof(*dup), 1);
*dup = *packet;
dup->payload = str_dup(&ev_pl);
dup->rtp = r;
@ -2764,7 +2764,7 @@ static int __handler_func_supplemental(struct codec_handler *h, struct media_pac
h->input_handler = sequencer_h;
h->output_handler = sequencer_h;
struct transcode_packet *packet = g_slice_alloc0(sizeof(*packet));
struct transcode_packet *packet = g_new0(__typeof(*packet), 1);
packet->packet_func = packet_func;
packet->dup_func = dup_func;
packet->handler = h;
@ -2802,7 +2802,7 @@ void codec_packet_free(void *pp) {
if (p->plain_free_func && p->plain.s)
p->plain_free_func(p->plain.s);
ssrc_ctx_put(&p->ssrc_out);
g_slice_free1(sizeof(*p), p);
g_free(p);
}
bool codec_packet_copy(struct codec_packet *p) {
char *buf = bufferpool_alloc(media_bufferpool, p->s.len + RTP_BUFFER_TAIL_ROOM);
@ -2812,7 +2812,7 @@ bool codec_packet_copy(struct codec_packet *p) {
return true;
}
struct codec_packet *codec_packet_dup(struct codec_packet *p) {
struct codec_packet *dup = g_slice_alloc0(sizeof(*p));
struct codec_packet *dup = g_new0(__typeof(*p), 1);
*dup = *p;
codec_packet_copy(dup);
if (dup->ssrc_out)
@ -3026,7 +3026,7 @@ static int handler_func_passthrough_ssrc(struct codec_handler *h, struct media_p
static void __transcode_packet_free(struct transcode_packet *p) {
free(p->payload);
g_slice_free1(sizeof(*p), p);
g_free(p);
}
static struct ssrc_entry *__ssrc_handler_new(void *p) {
@ -3060,7 +3060,7 @@ void codec_add_dtmf_event(struct codec_ssrc_handler *ch, int code, int level, ui
// this does not capture events when doing DTMF delay (dtmf_payload_type == -1)
// unless this is an injected event, in which case we check the real payload type
if (ch->handler->dtmf_payload_type != -1 || (injected && ch->handler->real_dtmf_payload_type != -1)) {
struct dtmf_event *ev = g_slice_alloc(sizeof(*ev));
struct dtmf_event *ev = g_new(__typeof(*ev), 1);
*ev = new_ev;
t_queue_push_tail(&ch->dtmf_events, ev);
}
@ -3171,7 +3171,7 @@ static void __buffer_delay_frame(struct delay_buffer *dbuf, struct codec_ssrc_ha
return;
}
struct delay_frame *dframe = g_slice_alloc0(sizeof(*dframe));
struct delay_frame *dframe = g_new0(__typeof(*dframe), 1);
dframe->frame = frame;
dframe->encoder_func = input_func;
dframe->ts = ts;
@ -3195,7 +3195,7 @@ static void __buffer_delay_raw(struct delay_buffer *dbuf, struct codec_handler *
return;
}
struct delay_frame *dframe = g_slice_alloc0(sizeof(*dframe));
struct delay_frame *dframe = g_new0(__typeof(*dframe), 1);
dframe->raw_func = input_func;
dframe->clockrate = clockrate;
dframe->handler = handler;
@ -3226,7 +3226,7 @@ static tc_code __buffer_delay_packet(struct delay_buffer *dbuf,
return TCC_OK;
}
struct delay_frame *dframe = g_slice_alloc0(sizeof(*dframe));
struct delay_frame *dframe = g_new0(__typeof(*dframe), 1);
dframe->packet_func = packet_func;
dframe->clockrate = clockrate;
dframe->ch = ch ? ssrc_handler_get(ch) : NULL;
@ -3282,7 +3282,7 @@ static bool __buffer_dtx(struct dtx_buffer *dtxb, struct codec_ssrc_handler *dec
unsigned long ts = packet ? packet->ts : 0;
// allocate packet object
struct dtx_packet *dtxp = g_slice_alloc0(sizeof(*dtxp));
struct dtx_packet *dtxp = g_new0(__typeof(*dtxp), 1);
dtxp->packet = packet;
dtxp->dtx_func = dtx_func;
if (decoder_handler)
@ -3344,7 +3344,7 @@ static void delay_frame_free(struct delay_frame *dframe) {
obj_release(dframe->input_ch);
if (dframe->packet)
__transcode_packet_free(dframe->packet);
g_slice_free1(sizeof(*dframe), dframe);
g_free(dframe);
}
static void delay_frame_send(struct delay_frame *dframe) {
send_buffered(&dframe->mp, log_level_index_transcoding);
@ -3361,7 +3361,7 @@ static void dtx_packet_free(struct dtx_packet *dtxp) {
media_packet_release(&dtxp->mp);
obj_release(dtxp->decoder_handler);
obj_release(dtxp->input_handler);
g_slice_free1(sizeof(*dtxp), dtxp);
g_free(dtxp);
}
static void delay_buffer_stop(struct delay_buffer **pcmbp) {
codec_timer_stop((struct codec_timer **) pcmbp);
@ -3398,7 +3398,7 @@ static void delay_frame_manipulate(struct delay_frame *dframe) {
if (dframe->ch->handler->real_dtmf_payload_type != -1) {
// add end event to queue
if (dframe->ch->dtmf_event.code) {
struct dtmf_event *ev = g_slice_alloc0(sizeof(*ev));
struct dtmf_event *ev = g_new0(__typeof(*ev), 1);
uint64_t ts = dframe->ch->encoder ? dframe->ch->encoder->next_pts
: dframe->ts;
*ev = (struct dtmf_event) { .code = 0, .volume = 0, .ts = ts };
@ -3433,7 +3433,7 @@ static void delay_frame_manipulate(struct delay_frame *dframe) {
if (dframe->ch->dtmf_event.code != dtmf_send->code) {
// XXX this should be switched to proper state tracking instead
// of using start/stop events
struct dtmf_event *ev = g_slice_alloc0(sizeof(*ev));
struct dtmf_event *ev = g_new0(__typeof(*ev), 1);
uint64_t ts = dframe->ch->encoder ? dframe->ch->encoder->next_pts
: dframe->ts;
*ev = (struct dtmf_event) { .code = dtmf_send->code,
@ -4054,7 +4054,7 @@ void codec_handlers_stop(codec_handlers_q *q, struct call_media *sink) {
static void silence_event_free(struct silence_event *p) {
g_slice_free1(sizeof(*p), p);
g_free(p);
}
#define __silence_detect_type(type) \
@ -4070,7 +4070,7 @@ static void __silence_detect_ ## type(struct codec_ssrc_handler *ch, AVFrame *fr
/* silence */ \
if (!last) { \
/* new event */ \
last = g_slice_alloc0(sizeof(*last)); \
last = g_new0(__typeof(*last), 1); \
last->start = frame->pts + i; \
t_queue_push_tail(&ch->silence_events, last); \
} \
@ -4896,7 +4896,7 @@ static int handler_func_transcode(struct codec_handler *h, struct media_packet *
atomic64_add(&h->stats_entry->bytes_input[2], mp->payload.len);
}
struct transcode_packet *packet = g_slice_alloc0(sizeof(*packet));
struct transcode_packet *packet = g_new0(__typeof(*packet), 1);
packet->packet_func = packet_decode;
packet->rtp = *mp->rtp;
packet->handler = h;
@ -5113,13 +5113,13 @@ static void codec_tracker_destroy(struct codec_tracker **sct) {
if (!*sct)
return;
g_hash_table_destroy((*sct)->touched);
g_slice_free1(sizeof(**sct), *sct);
g_free(*sct);
*sct = NULL;
#endif
}
static struct codec_tracker *codec_tracker_init(void) {
#ifdef WITH_TRANSCODING
struct codec_tracker *ret = g_slice_alloc0(sizeof(*ret));
struct codec_tracker *ret = g_new0(__typeof(*ret), 1);
ret->touched = g_hash_table_new(g_direct_hash, g_direct_equal);
return ret;
#else

@ -631,7 +631,7 @@ struct control_ng_stats* get_control_ng_stats(const sockaddr_t *addr) {
mutex_lock(&rtpe_cngs_lock);
cur = g_hash_table_lookup(rtpe_cngs_hash, addr);
if (!cur) {
cur = g_slice_alloc0(sizeof(struct control_ng_stats));
cur = g_new0(__typeof(*cur), 1);
cur->proxy = *addr;
ilogs(control, LOG_DEBUG,"Adding a proxy for control ng stats:%s", sockaddr_print_buf(addr));
@ -1107,7 +1107,7 @@ void control_ng_free(struct control_ng *c) {
GList *ll = g_hash_table_get_values(rtpe_cngs_hash);
for (GList *l = ll; l; l = l->next) {
struct control_ng_stats *s = l->data;
g_slice_free1(sizeof(*s), s);
g_free(s);
}
g_list_free(ll);
g_hash_table_destroy(rtpe_cngs_hash);

@ -860,7 +860,7 @@ static int aes_cm_session_key_init(struct crypto_context *c) {
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
c->session_key_ctx[0] = EVP_CIPHER_CTX_new();
#else
c->session_key_ctx[0] = g_slice_alloc(sizeof(EVP_CIPHER_CTX));
c->session_key_ctx[0] = g_new(EVP_CIPHER_CTX, 1);
EVP_CIPHER_CTX_init(c->session_key_ctx[0]);
#endif
EVP_EncryptInit_ex(c->session_key_ctx[0], c->params.crypto_suite->aes_evp, NULL,
@ -874,7 +874,7 @@ static int aes_gcm_session_key_init(struct crypto_context *c) {
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
c->session_key_ctx[0] = EVP_CIPHER_CTX_new();
#else
c->session_key_ctx[0] = g_slice_alloc(sizeof(EVP_CIPHER_CTX));
c->session_key_ctx[0] = g_new(EVP_CIPHER_CTX, 1);
EVP_CIPHER_CTX_init(c->session_key_ctx[0]);
#endif
return 0;
@ -903,7 +903,7 @@ static int aes_f8_session_key_init(struct crypto_context *c) {
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
c->session_key_ctx[1] = EVP_CIPHER_CTX_new();
#else
c->session_key_ctx[1] = g_slice_alloc(sizeof(EVP_CIPHER_CTX));
c->session_key_ctx[1] = g_new(EVP_CIPHER_CTX, 1);
EVP_CIPHER_CTX_init(c->session_key_ctx[1]);
#endif
EVP_EncryptInit_ex(c->session_key_ctx[1], EVP_aes_128_ecb(), NULL, m, NULL);
@ -924,7 +924,7 @@ static int evp_session_key_cleanup(struct crypto_context *c) {
EVP_CIPHER_CTX_free(c->session_key_ctx[i]);
#else
EVP_CIPHER_CTX_cleanup(c->session_key_ctx[i]);
g_slice_free1(sizeof(EVP_CIPHER_CTX), c->session_key_ctx[i]);
g_free(c->session_key_ctx[i]);
#endif
c->session_key_ctx[i] = NULL;
}

@ -210,14 +210,14 @@ static void dtmf_end_event(struct call_media *media, unsigned int event, unsigne
// don't add to recv list when it's injected, it can cause the list TS's to be out
// of order breaking the dtmf-security and letting the generated PCM frames through
if (!injected) {
struct dtmf_event *ev = g_slice_alloc0(sizeof(*ev));
struct dtmf_event *ev = g_new0(__typeof(*ev), 1);
*ev = (struct dtmf_event) { .code = 0, .ts = ts, .volume = 0 };
t_queue_push_tail(&media->dtmf_recv, ev);
}
// only add to send list if injected, a delayed send, or not being blocked
if (injected || !media->monologue->block_dtmf || media->monologue->dtmf_delay) {
struct dtmf_event *ev = g_slice_alloc0(sizeof(*ev));
struct dtmf_event *ev = g_new0(__typeof(*ev), 1);
*ev = (struct dtmf_event) { .code = 0, .ts = ts + media->monologue->dtmf_delay * clockrate / 1000,
.volume = 0, .block_dtmf = media->monologue->block_dtmf };
t_queue_push_tail(&media->dtmf_send, ev);
@ -497,7 +497,7 @@ static void dtmf_code_event(struct call_media *media, char event, uint64_t ts, i
// don't add to recv list when it's injected, it can cause the list TS's to be out
// of order breaking the dtmf-security and letting the generated PCM frames through
if (!injected) {
ev = g_slice_alloc0(sizeof(*ev));
ev = g_new0(__typeof(*ev), 1);
*ev = (struct dtmf_event) { .code = event, .ts = ts, .volume = volume,
.rand_code = '0' + (ssl_random() % 10), .index = media->dtmf_count };
t_queue_push_tail(&media->dtmf_recv, ev);
@ -505,7 +505,7 @@ static void dtmf_code_event(struct call_media *media, char event, uint64_t ts, i
// only add to send list if injected, a delayed send, or not being blocked
if (injected || !media->monologue->block_dtmf || media->monologue->dtmf_delay) {
ev = g_slice_alloc0(sizeof(*ev));
ev = g_new0(__typeof(*ev), 1);
*ev = (struct dtmf_event) { .code = event, .ts = ts + media->monologue->dtmf_delay * clockrate / 1000,
.volume = volume,
.block_dtmf = media->monologue->block_dtmf };
@ -632,7 +632,7 @@ void dtmf_dsp_event(const struct dtmf_event *new_event, struct dtmf_event *cur_e
}
void dtmf_event_free(struct dtmf_event *e) {
g_slice_free1(sizeof(*e), e);
g_free(e);
}
// returns: 0 = no DTMF. 1 = DTMF start event. 2 = DTMF in progress. 3 = DTMF end event.

@ -116,7 +116,7 @@ int pcre2_multi_match(pcre2_code *re, const char *s, unsigned int num, parse_fun
static void thread_join_me(void) {
pthread_t *me;
me = g_slice_alloc(sizeof(*me));
me = g_new(__typeof(*me), 1);
*me = pthread_self();
mutex_lock(&threads_lists_lock);
threads_to_join = g_list_prepend(threads_to_join, me);
@ -157,12 +157,12 @@ void threads_join_all(bool cancel) {
threads_to_join = g_list_delete_link(threads_to_join, threads_to_join);
l = g_list_find_custom(threads_running, t, thread_equal);
if (l) {
g_slice_free1(sizeof(*t), l->data);
g_free(l->data);
threads_running = g_list_delete_link(threads_running, l);
}
else
abort();
g_slice_free1(sizeof(*t), t);
g_free(t);
}
if ((!cancel && rtpe_shutdown) || (cancel && !threads_running)) {
@ -196,7 +196,7 @@ void thread_waker_del(struct thread_waker *wk) {
static void thread_detach_cleanup(void *dtp) {
struct detach_thread *dt = dtp;
g_slice_free1(sizeof(*dt), dt);
g_free(dt);
bufferpool_destroy(media_bufferpool);
#ifdef HAVE_LIBURING
if (rtpe_config.common.io_uring)
@ -211,7 +211,7 @@ static void *thread_detach_func(void *d) {
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
t = g_slice_alloc(sizeof(*t));
t = g_new(__typeof(*t), 1);
*t = pthread_self();
mutex_lock(&threads_lists_lock);
threads_running = g_list_prepend(threads_running, t);
@ -272,7 +272,7 @@ void thread_create_detach_prio(void (*f)(void *), void *d, const char *scheduler
{
struct detach_thread *dt;
dt = g_slice_alloc(sizeof(*dt));
dt = g_new(__typeof(*dt), 1);
dt->func = f;
dt->data = d;
dt->scheduler = scheduler;
@ -286,7 +286,7 @@ static void thread_looper_helper(void *fp) {
// move object to stack and free it, so we can be cancelled without having a leak
struct looper_thread *lhp = fp;
struct looper_thread lh = *lhp;
g_slice_free1(sizeof(*lhp), lhp);
g_free(lhp);
long long interval_us = lh.interval_us;
#ifdef ASAN_BUILD
@ -339,7 +339,7 @@ void thread_create_looper(enum thread_looper_action (*f)(void), const char *sche
const char *name,
long long interval_us)
{
struct looper_thread *lh = g_slice_alloc(sizeof(*lh));
struct looper_thread *lh = g_new(__typeof(*lh), 1);
*lh = (__typeof__(*lh)) {
.f = f,
.name = name,

@ -125,13 +125,13 @@ static void fragment_free(struct sdp_fragment *frag) {
sdp_streams_clear(&frag->streams);
call_ng_free_flags(&frag->flags);
obj_put(frag->ngbuf);
g_slice_free1(sizeof(*frag), frag);
g_free(frag);
}
static void queue_sdp_fragment(ng_buffer *ngbuf, call_t *call, str *key, sdp_streams_q *streams, sdp_ng_flags *flags) {
ilog(LOG_DEBUG, "Queuing up SDP fragment for " STR_FORMAT_M "/" STR_FORMAT_M,
STR_FMT_M(&flags->call_id), STR_FMT_M(&flags->from_tag));
struct sdp_fragment *frag = g_slice_alloc0(sizeof(*frag));
struct sdp_fragment *frag = g_new0(__typeof(*frag), 1);
frag->received = rtpe_now;
frag->ngbuf = obj_get(ngbuf);
if (streams) {
@ -279,7 +279,7 @@ static struct ice_candidate_pair *__pair_candidate(stream_fd *sfd, struct ice_ag
if (sfd->socket.family != cand->endpoint.address.family)
return NULL;
pair = g_slice_alloc0(sizeof(*pair));
pair = g_new0(__typeof(*pair), 1);
pair->agent = ag;
pair->remote_candidate = cand;
@ -549,7 +549,7 @@ void ice_update(struct ice_agent *ag, struct stream_params *sp, bool allow_reset
else {
ilogs(ice, LOG_DEBUG, "Learning new ICE candidate " STR_FORMAT_M ":%lu",
STR_FMT_M(&cand->foundation), cand->component_id);
dup = g_slice_alloc(sizeof(*dup));
dup = g_new(__typeof(*dup), 1);
__copy_cand(call, dup, cand);
t_hash_table_insert(ag->candidate_hash, dup, dup);
t_hash_table_insert(ag->cand_prio_hash, GUINT_TO_POINTER(dup->priority), dup);
@ -597,13 +597,13 @@ pair:
static void ice_candidate_free(struct ice_candidate *p) {
g_slice_free1(sizeof(*p), p);
g_free(p);
}
void ice_candidates_free(candidate_q *q) {
t_queue_clear_full(q, ice_candidate_free);
}
static void ice_candidate_pair_free(struct ice_candidate_pair *p) {
g_slice_free1(sizeof(struct ice_candidate_pair), p);
g_free(p);
}
static void ice_candidate_pairs_free(candidate_pair_q *q) {
t_queue_clear_full(q, ice_candidate_pair_free);
@ -983,7 +983,7 @@ static struct ice_candidate_pair *__learned_candidate(struct ice_agent *ag, stre
call_t *call = ag->call;
struct packet_stream *ps = sfd->stream;
cand = g_slice_alloc0(sizeof(*cand));
cand = g_new0(__typeof(*cand), 1);
cand->component_id = ps->component;
cand->transport = sfd->local_intf->spec->local_address.type; // XXX add socket type into socket_t?
cand->priority = priority;
@ -1016,7 +1016,7 @@ static struct ice_candidate_pair *__learned_candidate(struct ice_agent *ag, stre
/* this is possible if two distinct requests are received from the same NAT IP
* address, but from different ports. we cannot distinguish such candidates and
* will drop the one with the lower priority */
g_slice_free1(sizeof(*cand), cand);
g_free(cand);
pair = __pair_lookup(ag, old_cand, sfd->local_intf);
if (pair)
goto out; /* nothing to do */

@ -193,7 +193,7 @@ static const char *janus_videoroom_create(struct janus_session *session, struct
return "User already exists in a room";
// create new videoroom
struct janus_room *room = g_slice_alloc0(sizeof(*room));
struct janus_room *room = g_new0(__typeof(*room), 1);
if (json_reader_read_member(reader, "publishers"))
room->num_publishers = jr_str_int(reader);
@ -313,7 +313,7 @@ static const char *janus_videoroom_destroy(struct janus_session *session,
t_hash_table_destroy(room->publishers);
t_hash_table_destroy(room->subscribers);
t_hash_table_destroy(room->feeds);
g_slice_free1(sizeof(*room), room);
g_free(room);
//XXX notify?
@ -461,7 +461,7 @@ TYPED_GQUEUE(janus_ret_streams, uint64_t);
static void janus_clear_ret_streams(janus_ret_streams_q *q) {
uint64_t *id;
while ((id = t_queue_pop_head(q)))
g_slice_free1(sizeof(*id), id);
g_free(id);
}
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(janus_ret_streams_q, janus_clear_ret_streams);
@ -605,7 +605,7 @@ static const char *janus_videoroom_join(struct websocket_message *wm, struct jan
g_string_append_printf(feed_ids, "%" PRIu64 ", ", fid);
uint64_t *fidp = g_slice_alloc(sizeof(*fidp));
uint64_t *fidp = g_new(__typeof(*fidp), 1);
*fidp = fid;
t_queue_push_tail(&ret_streams, fidp);
}
@ -1313,7 +1313,7 @@ static const char *janus_attach(JsonReader *reader, JsonBuilder *builder, struct
return "Unsupported plugin";
json_reader_end_member(reader);
struct janus_handle *handle = g_slice_alloc0(sizeof(*handle));
struct janus_handle *handle = g_new0(__typeof(*handle), 1);
mutex_lock(&janus_lock);
handle->session = obj_get(session);
uint64_t handle_id = 0;
@ -1348,7 +1348,7 @@ static void janus_destroy_handle(struct janus_handle *handle) {
// destroy handle
if (handle->session)
obj_put(handle->session);
g_slice_free1(sizeof(*handle), handle);
g_free(handle);
if (!room_id)
return;
@ -1640,9 +1640,9 @@ static const char *janus_trickle(JsonReader *reader, struct janus_session *sessi
call_ng_flags_init(&flags, OP_OTHER);
// then the contained structures, and add them in
struct stream_params *sp = g_slice_alloc0(sizeof(*sp));
struct stream_params *sp = g_new0(__typeof(*sp), 1);
t_queue_push_tail(&streams, sp);
struct ice_candidate *cand = g_slice_alloc0(sizeof(*cand));
struct ice_candidate *cand = g_new0(__typeof(*cand), 1);
t_queue_push_tail(&sp->ice_candidates, cand);
// allocate and parse candidate

@ -112,7 +112,7 @@ static struct jb_packet* get_jb_packet(struct media_packet *mp, const str *s) {
return NULL;
}
struct jb_packet *p = g_slice_alloc0(sizeof(*p));
struct jb_packet *p = g_new0(__typeof(*p), 1);
p->buf = buf;
media_packet_copy(&p->mp, mp);
@ -448,6 +448,6 @@ void jb_packet_free(struct jb_packet **jbp) {
bufferpool_unref((*jbp)->buf);
media_packet_release(&(*jbp)->mp);
g_slice_free1(sizeof(**jbp), *jbp);
g_free(*jbp);
*jbp = NULL;
}

@ -214,7 +214,7 @@ static void __find_if_name(const char *s, struct ifaddrs *ifas, GQueue *addrs) {
if (!ifa->ifa_addr)
continue;
addr = g_slice_alloc(sizeof(*addr));
addr = g_new(__typeof(*addr), 1);
if (ifa->ifa_addr->sa_family == AF_INET) {
struct sockaddr_in *sin = (void *) ifa->ifa_addr;
addr->family = get_socket_family_enum(SF_IP4);
@ -224,14 +224,14 @@ static void __find_if_name(const char *s, struct ifaddrs *ifas, GQueue *addrs) {
struct sockaddr_in6 *sin = (void *) ifa->ifa_addr;
if (sin->sin6_scope_id) {
// link-local
g_slice_free1(sizeof(*addr), addr);
g_free(addr);
continue;
}
addr->family = get_socket_family_enum(SF_IP6);
addr->ipv6 = sin->sin6_addr;
}
else {
g_slice_free1(sizeof(*addr), addr);
g_free(addr);
continue;
}
@ -256,7 +256,7 @@ static void __resolve_ifname(const char *s, GQueue *addrs) {
}
for (struct addrinfo *r = res; r; r = r->ai_next) {
sockaddr_t *addr = g_slice_alloc0(sizeof(*addr));
sockaddr_t *addr = g_new0(__typeof(*addr), 1);
if (r->ai_family == AF_INET) {
struct sockaddr_in *sin = (void *) r->ai_addr;
@ -271,7 +271,7 @@ static void __resolve_ifname(const char *s, GQueue *addrs) {
addr->ipv6 = sin->sin6_addr;
}
else {
g_slice_free1(sizeof(*addr), addr);
g_free(addr);
continue;
}
@ -284,7 +284,7 @@ static void __resolve_ifname(const char *s, GQueue *addrs) {
}
static void if_add_alias(intf_config_q *q, const str *name, const char *alias) {
struct intf_config *ifa = g_slice_alloc0(sizeof(*ifa));
struct intf_config *ifa = g_new0(__typeof(*ifa), 1);
ifa->name = str_dup_str(name);
ifa->alias = STR_DUP(alias);
t_queue_push_tail(q, ifa);
@ -298,14 +298,14 @@ static bool if_add(intf_config_q *q, struct ifaddrs *ifas, const str *name,
GQueue addrs = G_QUEUE_INIT;
/* address */
sockaddr_t *addr = g_slice_alloc(sizeof(*addr));
sockaddr_t *addr = g_new(__typeof(*addr), 1);
if (sockaddr_parse_any(addr, address)) {
if (is_addr_unspecified(addr))
return false;
g_queue_push_tail(&addrs, addr);
}
else {
g_slice_free1(sizeof(*addr), addr);
g_free(addr);
// could be an interface name?
ilog(LOG_DEBUG, "Could not parse '%s' as network address, checking to see if "
"it's an interface", address);
@ -334,7 +334,7 @@ static bool if_add(intf_config_q *q, struct ifaddrs *ifas, const str *name,
}
while ((addr = g_queue_pop_head(&addrs))) {
struct intf_config *ifa = g_slice_alloc0(sizeof(*ifa));
struct intf_config *ifa = g_new0(__typeof(*ifa), 1);
ifa->name = str_dup_str(name);
ifa->local_address.addr = *addr;
ifa->local_address.type = socktype_udp;
@ -352,7 +352,7 @@ static bool if_add(intf_config_q *q, struct ifaddrs *ifas, const str *name,
t_queue_push_tail(q, ifa);
g_slice_free1(sizeof(*addr), addr);
g_free(addr);
}
return true;
@ -556,7 +556,7 @@ static void parse_cn_payload(str *out, char **in, const char *def, const char *n
static endpoint_t *endpoint_dup(const endpoint_t *e) {
endpoint_t *r = g_slice_alloc(sizeof(*r));
endpoint_t *r = g_new(__typeof(*r), 1);
*r = *e;
return r;
}
@ -568,7 +568,7 @@ static void endpoint_list_dup(GQueue *out, const GQueue *in) {
static void endpoint_list_free(GQueue *q) {
endpoint_t *ep;
while ((ep = g_queue_pop_head(q)))
g_slice_free1(sizeof(*ep), ep);
g_free(ep);
}
static void parse_listen_list(GQueue *out, char **epv, const char *option) {
if (!epv)
@ -1360,7 +1360,7 @@ static void fill_initial_rtpe_cfg(struct rtpengine_config* ini_rtpe_cfg) {
struct intf_config* gptr_data;
for (__auto_type l = rtpe_config.interfaces.head; l ; l=l->next) {
gptr_data = g_slice_alloc0(sizeof(*gptr_data));
gptr_data = g_new0(__typeof(*gptr_data), 1);
memcpy(gptr_data, l->data, sizeof(*gptr_data));
gptr_data->name = str_dup_str(&l->data->name);
gptr_data->alias = str_dup_str(&l->data->alias);
@ -1399,7 +1399,7 @@ RTPE_CONFIG_ENDPOINT_QUEUE_PARAMS
static void free_config_interfaces(struct intf_config *i) {
str_free_dup(&i->name);
str_free_dup(&i->alias);
g_slice_free1(sizeof(*i), i);
g_free(i);
}
static void unfill_initial_rtpe_cfg(struct rtpengine_config* ini_rtpe_cfg) {

@ -678,7 +678,7 @@ static void media_player_cached_reader_start(struct media_player *mp, str_case_v
static void cache_packet_free(struct media_player_cache_packet *p) {
RTPE_GAUGE_ADD(player_cache, -1 * (ssize_t) p->s.len);
bufferpool_unref(p->buf);
g_slice_free1(sizeof(*p), p);
g_free(p);
}
@ -825,7 +825,7 @@ static void packet_encoded_cache(AVPacket *pkt, struct codec_ssrc_handler *ch, s
{
struct media_player_cache_entry *entry = mp->cache_entry;
struct media_player_cache_packet *ep = g_slice_alloc0(sizeof(*ep));
struct media_player_cache_packet *ep = g_new0(__typeof(*ep), 1);
long duration = fraction_divl(pkt->duration, cr_fact);
*ep = (__typeof__(*ep)) {

@ -833,7 +833,7 @@ static void __add_intf_rr_1(struct logical_intf *lif, str *name_base, sockfamily
key.preferred_family = fam;
struct intf_rr *rr = t_hash_table_lookup(__logical_intf_name_family_rr_hash, &key);
if (!rr) {
rr = g_slice_alloc0(sizeof(*rr));
rr = g_new0(__typeof(*rr), 1);
rr->hash_key = key;
mutex_init(&rr->lock);
t_hash_table_insert(__logical_intf_name_family_rr_hash, &rr->hash_key, rr);
@ -881,7 +881,7 @@ static void __interface_append(struct intf_config *ifa, sockfamily_t *fam, bool
if (ifa->alias.len) // handled in second run
return;
lif = g_slice_alloc0(sizeof(*lif));
lif = g_new0(__typeof(*lif), 1);
t_queue_init(&lif->list);
lif->name = ifa->name;
lif->name_base = ifa->name_base;
@ -922,7 +922,7 @@ static void __interface_append(struct intf_config *ifa, sockfamily_t *fam, bool
|| ifa->port_max > 65535 || ifa->port_min > ifa->port_max)
die("Invalid RTP port range (%d > %d)", ifa->port_min, ifa->port_max);
spec = g_slice_alloc0(sizeof(*spec));
spec = g_new0(__typeof(*spec), 1);
spec->local_address = ifa->local_address;
spec->port_pool.free_ports = g_new0(ports_list *, ifa->port_max - ifa->port_min + 1);
spec->port_pool.min = ifa->port_min;
@ -1075,7 +1075,7 @@ static void release_port_push(void *p) {
static void release_port_poller(struct socket_port_link *spl, struct poller *poller) {
if (!spl->socket.local.port || spl->socket.fd == -1)
return;
struct late_port_release *lpr = g_slice_alloc(sizeof(*lpr));
struct late_port_release *lpr = g_new(__typeof(*lpr), 1);
move_socket(&lpr->socket, &spl->socket);
lpr->pp = spl->pp;
lpr->pp_links = spl->links;
@ -1133,7 +1133,7 @@ enum thread_looper_action release_closed_sockets(void) {
while ((lpr = t_queue_pop_head(&ports_left))) {
release_port_now(&lpr->socket, &lpr->pp_links, lpr->pp);
g_slice_free1(sizeof(*lpr), lpr);
g_free(lpr);
}
}
@ -1368,7 +1368,7 @@ bool get_consecutive_ports(socket_intf_list_q *out, unsigned int num_ports, unsi
loc = l->data;
il = g_slice_alloc0(sizeof(*il));
il = g_new0(__typeof(*il), 1);
il->local_intf = loc;
t_queue_push_tail(out, il);
if (G_LIKELY(__get_consecutive_ports(&il->list, num_ports, loc->spec, label))) {
@ -1399,15 +1399,15 @@ void free_socket_intf_list(struct socket_intf_list *il) {
while ((spl = t_queue_pop_head(&il->list)))
free_port(spl);
g_slice_free1(sizeof(*il), il);
g_free(il);
}
void free_sfd_intf_list(struct sfd_intf_list *il) {
t_queue_clear(&il->list);
g_slice_free1(sizeof(*il), il);
g_free(il);
}
void free_release_sfd_intf_list(struct sfd_intf_list *il) {
t_queue_clear_full(&il->list, stream_fd_release);
g_slice_free1(sizeof(*il), il);
g_free(il);
}
@ -3366,7 +3366,7 @@ void interfaces_free(void) {
mutex_destroy(&pp->free_list_lock);
t_queue_clear(&pp->overlaps);
g_free(pp->free_ports);
g_slice_free1(sizeof(*spec), spec);
g_free(spec);
}
t_queue_free(spec_q);
}
@ -3377,7 +3377,7 @@ void interfaces_free(void) {
struct intf_rr *rr;
while (t_hash_table_iter_next(&r_iter, NULL, &rr)) {
t_queue_clear(&rr->logical_intfs);
g_slice_free1(sizeof(*rr), rr);
g_free(rr);
}
t_hash_table_destroy(__logical_intf_name_family_rr_hash);
@ -3387,7 +3387,7 @@ void interfaces_free(void) {
__auto_type lif = t_queue_pop_head(q);
t_hash_table_destroy(lif->rr_specs);
t_queue_clear(&lif->list);
g_slice_free1(sizeof(*lif), lif);
g_free(lif);
}
}
@ -3397,7 +3397,7 @@ void interfaces_free(void) {
static void interface_stats_block_free(void *p) {
g_slice_free1(sizeof(struct interface_stats_interval), p);
g_free(p);
}
void interface_sampled_rate_stats_init(struct interface_sampled_rate_stats *s) {
s->ht = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL,
@ -3413,7 +3413,7 @@ struct interface_stats_block *interface_sampled_rate_stats_get(struct interface_
return NULL;
struct interface_stats_interval *ret = g_hash_table_lookup(s->ht, lif);
if (!ret) {
ret = g_slice_alloc0(sizeof(*ret));
ret = g_new0(__typeof(*ret), 1);
g_hash_table_insert(s->ht, lif, ret);
}
if (ret->last_run.tv_sec)

@ -112,7 +112,7 @@ static void check_matched_queue(struct nftnl_rule *r, struct iterate_callbacks *
return;
uint64_t handle = nftnl_rule_get_u64(r, NFTNL_RULE_HANDLE);
g_queue_push_tail(&callbacks->iterate_scratch.handles, g_slice_dup(uint64_t, &handle));
g_queue_push_tail(&callbacks->iterate_scratch.handles, g_memdup2(&handle, sizeof(handle)));
}
@ -285,7 +285,7 @@ static const char *iterate_delete_rules(struct mnl_socket *nl, int family, const
uint64_t *handle = g_queue_pop_head(&callbacks->iterate_scratch.handles);
// transfer to stack and free
uint64_t h = *handle;
g_slice_free(uint64_t, handle);
g_free(handle);
const char *err = delete_rules(nl, family, chain, seq, set_rule_handle, &h);
if (err)

@ -361,7 +361,7 @@ void recording_start_daemon(call_t *call) {
}
ilog(LOG_NOTICE, "Turning on call recording.");
call->recording = g_slice_alloc0(sizeof(struct recording));
call->recording = g_new0(struct recording, 1);
g_autoptr(char) escaped_callid = g_uri_escape_string(call->callid.s, NULL, 0);
if (!call->recording_meta_prefix.len) {
const int rand_bytes = 8;
@ -779,7 +779,7 @@ void recording_finish(call_t *call, bool discard) {
_rm(finish, call, discard);
g_slice_free1(sizeof(*(recording)), recording);
g_free(recording);
call->recording = NULL;
}

@ -887,7 +887,7 @@ void redis_notify_loop(void *d) {
struct redis *redis_new(const endpoint_t *ep, int db, const char *hostname, const char *auth,
enum redis_role role, int no_redis_required, bool update_resolve) {
struct redis *r;
r = g_slice_alloc0(sizeof(*r));
r = g_new0(struct redis, 1);
r->endpoint = *ep;
sockaddr_print(&ep->address, r->host, sizeof(r->host));
@ -919,7 +919,7 @@ struct redis *redis_new(const endpoint_t *ep, int db, const char *hostname, cons
err:
mutex_destroy(&r->lock);
g_slice_free1(sizeof(*r), r);
g_free(r);
return NULL;
}
@ -940,7 +940,7 @@ void redis_close(struct redis *r) {
redisFree(r->ctx);
r->ctx = NULL;
mutex_destroy(&r->lock);
g_slice_free1(sizeof(*r), r);
g_free(r);
}
static void redis_count_err_and_disable(struct redis *r)
@ -1355,11 +1355,11 @@ static int redis_hash_get_sdes_params(sdes_q *out, const struct redis_hash *h, c
snprintf(tagkey, sizeof(tagkey), "%s_tag", kk);
if (redis_hash_get_unsigned(&tag, h, tagkey))
break;
struct crypto_params_sdes *cps = g_slice_alloc0(sizeof(*cps));
struct crypto_params_sdes *cps = g_new0(__typeof(*cps), 1);
cps->tag = tag;
int ret = redis_hash_get_sdes_params1(&cps->params, h, kk);
if (ret) {
g_slice_free1(sizeof(*cps), cps);
g_free(cps);
if (ret == 1)
return 0;
return -1;
@ -1514,7 +1514,7 @@ static int redis_tags(call_t *c, struct redis_list *tags, parser_arg arg) {
ml->sdp_session_timing = call_str_cpy(&s);
/* o= */
if (!redis_hash_get_str(&s, rh, "sdp_orig_parsed")) {
ml->session_sdp_orig = g_slice_alloc0(sizeof(*ml->session_sdp_orig));
ml->session_sdp_orig = g_new0(__typeof(*ml->session_sdp_orig), 1);
ml->session_sdp_orig->parsed = 1;
redis_hash_get_llu(&ml->session_sdp_orig->version_num, rh, "sdp_orig_version_num");
if (!redis_hash_get_str(&s, rh, "sdp_orig_username"))
@ -1532,7 +1532,7 @@ static int redis_tags(call_t *c, struct redis_list *tags, parser_arg arg) {
}
/* o= last used of the other side*/
if (!redis_hash_get_str(&s, rh, "last_sdp_orig_parsed")) {
ml->session_last_sdp_orig = g_slice_alloc0(sizeof(*ml->session_last_sdp_orig));
ml->session_last_sdp_orig = g_new0(__typeof(*ml->session_last_sdp_orig), 1);
ml->session_last_sdp_orig->parsed = 1;
redis_hash_get_llu(&ml->session_last_sdp_orig->version_num, rh, "last_sdp_orig_version_num");
if (!redis_hash_get_str(&s, rh, "last_sdp_orig_username"))
@ -1932,7 +1932,7 @@ static int rbl_cb_intf_sfds(str *s, callback_arg_t qp, struct redis_list *list,
void *sfd;
if (!strncmp(s->s, "loc-", 4)) {
il = g_slice_alloc0(sizeof(*il));
il = g_new0(__typeof(*il), 1);
em = ptr;
i = atoi(s->s+4);
il->local_intf = g_queue_peek_nth((GQueue*) &em->logical_intf->list, i);

@ -506,7 +506,7 @@ static struct rtcp_header *rtcp_length_check(str *s, size_t min_len, unsigned in
static struct rtcp_chain_element *rtcp_new_element(struct rtcp_header *p, unsigned int len) {
struct rtcp_chain_element *el;
el = g_slice_alloc(sizeof(*el));
el = g_new(__typeof(*el), 1);
el->type = p->pt;
el->len = len;
el->buf = p;
@ -644,7 +644,7 @@ next:
static void rtcp_ce_free(void *p) {
g_slice_free1(sizeof(struct rtcp_chain_element), p);
g_free(p);
}
void rtcp_list_free(GQueue *q) {
g_queue_clear_full(q, rtcp_ce_free);
@ -1481,7 +1481,7 @@ static GString *rtcp_sender_report(struct ssrc_sender_report *ssr,
};
if (srrs) {
struct ssrc_receiver_report *srr = g_slice_alloc(sizeof(*srr));
struct ssrc_receiver_report *srr = g_new(__typeof(*srr), 1);
*srr = (struct ssrc_receiver_report) {
.from = ssrc_out,
.ssrc = s->parent->h.ssrc,
@ -1624,7 +1624,7 @@ void rtcp_send_report(struct call_media *media, struct ssrc_ctx *ssrc_out) {
}
while (srrs.length) {
struct ssrc_receiver_report *srr = g_queue_pop_head(&srrs);
g_slice_free1(sizeof(*srr), srr);
g_free(srr);
}
}

@ -1281,7 +1281,7 @@ int sdp_parse(str *body, sdp_sessions_q *sessions, const sdp_ng_flags *flags) {
}
new_session:
session = g_slice_alloc0(sizeof(*session));
session = g_new0(__typeof(*session), 1);
t_queue_init(&session->media_streams);
attrs_init(&session->attributes);
t_queue_push_tail(sessions, session);
@ -1302,7 +1302,7 @@ new_session:
break;
case 'm':
media = g_slice_alloc0(sizeof(*media));
media = g_new0(__typeof(*media), 1);
media->session = session;
attrs_init(&media->attributes);
errstr = "Error parsing m= line";
@ -1323,7 +1323,7 @@ new_session:
break;
case 'a':
attr = g_slice_alloc0(sizeof(*attr));
attr = g_new0(__typeof(*attr), 1);
attr->full_line = full_line;
attr->strs.line_value = value;
@ -1425,7 +1425,7 @@ error:
}
static void attr_free(struct sdp_attribute *p) {
g_slice_free1(sizeof(*p), p);
g_free(p);
}
static void free_attributes(struct sdp_attributes *a) {
/* g_hash_table_destroy(a->name_hash); */
@ -1437,12 +1437,12 @@ static void free_attributes(struct sdp_attributes *a) {
static void media_free(struct sdp_media *media) {
free_attributes(&media->attributes);
str_slice_q_clear_full(&media->format_list);
g_slice_free1(sizeof(*media), media);
g_free(media);
}
static void session_free(struct sdp_session *session) {
t_queue_clear_full(&session->media_streams, media_free);
free_attributes(&session->attributes);
g_slice_free1(sizeof(*session), session);
g_free(session);
}
void sdp_sessions_clear(sdp_sessions_q *sessions) {
t_queue_clear_full(sessions, session_free);
@ -1599,7 +1599,7 @@ static void __sdp_ice(struct stream_params *sp, struct sdp_media *media) {
ac = &attr->candidate;
if (!ac->parsed)
continue;
cand = g_slice_alloc(sizeof(*cand));
cand = g_new(__typeof(*cand), 1);
*cand = ac->cand_parsed;
t_queue_push_tail(&sp->ice_candidates, cand);
}
@ -1691,7 +1691,7 @@ static void sp_free(struct stream_params *s) {
crypto_params_sdes_queue_clear(&s->sdes_params);
t_queue_clear_full(&s->generic_attributes, sdp_attr_free);
t_queue_clear_full(&s->all_attributes, sdp_attr_free);
g_slice_free1(sizeof(*s), s);
g_free(s);
}
@ -1783,7 +1783,7 @@ void sdp_attr_free(struct sdp_attr *c) {
}
sdp_origin *sdp_orig_dup(const sdp_origin *orig) {
sdp_origin *copy = g_slice_alloc0(sizeof(*copy));
sdp_origin *copy = g_new0(__typeof(*copy), 1);
copy->username = call_str_cpy(&orig->username);
copy->session_id = call_str_cpy(&orig->session_id);
copy->version_str = call_str_cpy(&orig->version_str);
@ -1800,7 +1800,7 @@ sdp_origin *sdp_orig_dup(const sdp_origin *orig) {
}
void sdp_orig_free(sdp_origin *o) {
g_slice_free1(sizeof(*o), o);
g_free(o);
}
static void sdp_attr_append1(sdp_attr_q *dst, const struct sdp_attribute *attr) {
@ -1869,7 +1869,7 @@ int sdp_streams(const sdp_sessions_q *sessions, sdp_streams_q *streams, sdp_ng_f
for (__auto_type k = session->media_streams.head; k; k = k->next) {
media = k->data;
sp = g_slice_alloc0(sizeof(*sp));
sp = g_new0(__typeof(*sp), 1);
sp->index = ++num;
codec_store_init(&sp->codecs, NULL);
sp->media_sdp_id = media->media_sdp_id;
@ -1925,7 +1925,7 @@ int sdp_streams(const sdp_sessions_q *sessions, sdp_streams_q *streams, sdp_ng_f
attributes_q *attrs = attr_list_get_by_id(&media->attributes, ATTR_CRYPTO);
for (__auto_type ll = attrs ? attrs->head : NULL; ll; ll = ll->next) {
attr = ll->data;
struct crypto_params_sdes *cps = g_slice_alloc0(sizeof(*cps));
struct crypto_params_sdes *cps = g_new0(__typeof(*cps), 1);
t_queue_push_tail(&sp->sdes_params, cps);
cps->params.crypto_suite = attr->crypto.crypto_suite;
@ -2050,7 +2050,7 @@ next:
error:
ilog(LOG_WARNING, "Failed to extract streams from SDP: %s", errstr);
g_slice_free1(sizeof(*sp), sp);
g_free(sp);
return -1;
}

@ -58,13 +58,13 @@ static void add_ssrc_entry(uint32_t ssrc, struct ssrc_entry *ent, struct ssrc_ha
obj_hold(ent); // queue entry
}
static void free_sender_report(struct ssrc_sender_report_item *i) {
g_slice_free1(sizeof(*i), i);
g_free(i);
}
static void free_rr_time(struct ssrc_rr_time_item *i) {
g_slice_free1(sizeof(*i), i);
g_free(i);
}
static void free_stats_block(struct ssrc_stats_block *ssb) {
g_slice_free1(sizeof(*ssb), ssb);
g_free(ssb);
}
static void __free_ssrc_entry_call(struct ssrc_entry_call *e) {
g_queue_clear_full(&e->sender_reports, (GDestroyNotify) free_sender_report);
@ -280,7 +280,7 @@ void free_ssrc_hash(struct ssrc_hash **ht) {
g_queue_clear_full(&(*ht)->q, ssrc_entry_put);
if ((*ht)->precreat)
obj_put((struct ssrc_entry *) (*ht)->precreat);
g_slice_free1(sizeof(**ht), *ht);
g_free(*ht);
*ht = NULL;
}
void ssrc_hash_foreach(struct ssrc_hash *sh, void (*f)(void *, void *), void *ptr) {
@ -300,7 +300,7 @@ void ssrc_hash_foreach(struct ssrc_hash *sh, void (*f)(void *, void *), void *pt
struct ssrc_hash *create_ssrc_hash_full_fast(ssrc_create_func_t cfunc, void *uptr) {
struct ssrc_hash *ret;
ret = g_slice_alloc0(sizeof(*ret));
ret = g_new0(__typeof(*ret), 1);
ret->ht = g_hash_table_new_full(uint32_hash, uint32_eq, NULL, ssrc_entry_put);
rwlock_init(&ret->lock);
ret->create_func = cfunc;
@ -335,7 +335,7 @@ static void *__do_time_report_item(struct call_media *m, size_t struct_size, siz
struct ssrc_entry *e;
struct ssrc_time_item *sti;
sti = g_slice_alloc0(struct_size);
sti = g_malloc0(struct_size);
sti->received = *tv;
sti->ntp_middle_bits = ntp_msw << 16 | ntp_lsw >> 16;
sti->ntp_ts = ntp_ts_to_double(ntp_msw, ntp_lsw);
@ -499,7 +499,7 @@ void ssrc_receiver_report(struct call_media *m, stream_fd *sfd, const struct ssr
if (other_e->last_rtt_xr > 0) { // use the RTT from RTCP-XR (in ms)
rtt_end2end = (long long) other_e->last_rtt_xr * 1000LL;
}
struct ssrc_stats_block *ssb = g_slice_alloc(sizeof(*ssb));
struct ssrc_stats_block *ssb = g_new(__typeof(*ssb), 1);
*ssb = (struct ssrc_stats_block) {
.jitter = jitter,
.rtt = rtt_end2end,

@ -233,7 +233,7 @@ INLINE void metric_push(stats_metric_q *ret, stats_metric *m) {
static void add_metric(stats_metric_q *ret, const char *label, const char *desc, const char *fmt1, const char *fmt2, ...) {
va_list ap;
stats_metric *m = g_slice_alloc0(sizeof(*m));
stats_metric *m = g_new0(__typeof(*m), 1);
if (label)
m->label = g_strdup(label);
if (desc)
@ -276,7 +276,7 @@ static void add_metric(stats_metric_q *ret, const char *label, const char *desc,
static void add_header(stats_metric_q *ret, const char *fmt1, const char *fmt2, ...) {
va_list ap;
stats_metric *m = g_slice_alloc0(sizeof(*m));
stats_metric *m = g_new0(__typeof(*m), 1);
if (fmt1) {
va_start(ap, fmt2); // coverity[copy_paste_error : FALSE]
m->label = g_strdup_vprintf(fmt1, ap);
@ -926,7 +926,7 @@ static void free_stats_metric(stats_metric *m) {
g_free(m->value_short);
g_free(m->value_raw);
g_free(m->prom_label);
g_slice_free1(sizeof(*m), m);
g_free(m);
}
void statistics_free_metrics(stats_metric_q *q) {

@ -306,7 +306,7 @@ static bool t38_pcm_player(struct media_player *mp) {
static void __udptl_packet_free(struct udptl_packet *p) {
if (p->s)
free(p->s);
g_slice_free1(sizeof(*p), p);
g_free(p);
}
@ -568,7 +568,7 @@ static int __get_udptl(str *piece, str *s) {
static struct udptl_packet *__make_udptl_packet(const str *piece, uint16_t seq) {
struct udptl_packet *up = g_slice_alloc0(sizeof(*up));
struct udptl_packet *up = g_new0(__typeof(*up), 1);
up->p.seq = seq;
up->s = str_dup(piece);
return up;

@ -67,7 +67,7 @@ static mutex_t websocket_service_lock = MUTEX_STATIC_INIT;
static struct websocket_message *websocket_message_new(struct websocket_conn *wc) {
struct websocket_message *wm = g_slice_alloc0(sizeof(*wm));
struct websocket_message *wm = g_new0(__typeof(*wm), 1);
wm->body = g_string_new("");
wm->wc = wc;
return wm;
@ -79,13 +79,13 @@ static void websocket_message_free(struct websocket_message **wm) {
g_string_free((*wm)->body, TRUE);
if ((*wm)->uri)
free((*wm)->uri);
g_slice_free1(sizeof(**wm), *wm);
g_free(*wm);
*wm = NULL;
}
static struct websocket_output *websocket_output_new(void) {
struct websocket_output *wo = g_slice_alloc0(sizeof(*wo));
struct websocket_output *wo = g_new0(__typeof(*wo), 1);
// str remains NULL -> unused output slot
return wo;
}
@ -93,7 +93,7 @@ static struct websocket_output *websocket_output_new(void) {
static void websocket_output_free(struct websocket_output *wo) {
if (wo->str)
g_string_free(wo->str, TRUE);
g_slice_free1(sizeof(*wo), wo);
g_free(wo);
}
@ -743,7 +743,7 @@ static void websocket_conn_cleanup(struct websocket_conn *wc) {
g_string_free(wc->wm->body, TRUE);
if (wc->wm->uri)
free(wc->wm->uri);
g_slice_free1(sizeof(*wc->wm), wc->wm);
g_free(wc->wm);
wc->wm = NULL;
t_queue_clear_full(&wc->output_q, websocket_output_free);
if (wc->uri)
@ -1059,7 +1059,7 @@ static void websocket_cleanup(void) {
while (websocket_vhost_configs.length) {
struct lws_context_creation_info *vhost = g_queue_pop_head(&websocket_vhost_configs);
g_free((void *) vhost->iface);
g_slice_free1(sizeof(*vhost), vhost);
g_free(vhost);
}
}
@ -1131,7 +1131,7 @@ int websocket_init(void) {
ipv6_fail = true;
continue;
}
struct lws_context_creation_info *vhost = g_slice_alloc(sizeof(*vhost));
struct lws_context_creation_info *vhost = g_new(__typeof(*vhost), 1);
g_queue_push_tail(&websocket_vhost_configs, vhost);
*vhost = (struct lws_context_creation_info) {
@ -1178,7 +1178,7 @@ int websocket_init(void) {
ipv6_fail = true;
continue;
}
struct lws_context_creation_info *vhost = g_slice_alloc(sizeof(*vhost));
struct lws_context_creation_info *vhost = g_new(__typeof(*vhost), 1);
g_queue_push_tail(&websocket_vhost_configs, vhost);
*vhost = (struct lws_context_creation_info) {

@ -372,7 +372,7 @@ INLINE struct sdp_manipulations *sdp_manipulations_get_create_by_id(struct sdp_m
if (id < 0 || id >= __MT_MAX)
return NULL;
if (!array[id])
array[id] = g_slice_alloc0(sizeof(*array[id]));
array[id] = g_new0(__typeof(*array[id]), 1);
return array[id];
}
INLINE struct sdp_manipulations *sdp_manipulations_get_by_name(struct sdp_manipulations * array[__MT_MAX], const str *s) {

@ -209,7 +209,7 @@ INLINE int crypto_params_cmp(const struct crypto_params *a, const struct crypto_
}
INLINE void crypto_params_sdes_free(struct crypto_params_sdes *cps) {
crypto_params_cleanup(&cps->params);
g_slice_free1(sizeof(*cps), cps);
g_free(cps);
}
INLINE void crypto_params_sdes_queue_clear(sdes_q *q) {
t_queue_clear_full(q, crypto_params_sdes_free);
@ -217,7 +217,7 @@ INLINE void crypto_params_sdes_queue_clear(sdes_q *q) {
INLINE void crypto_params_sdes_queue_copy(sdes_q *dst, const sdes_q *src) {
for (auto_iter(l, src->head); l; l = l->next) {
struct crypto_params_sdes *cps = l->data;
struct crypto_params_sdes *cpy = g_slice_alloc(sizeof(*cpy));
struct crypto_params_sdes *cpy = g_new(__typeof(*cpy), 1);
*cpy = *cps;
cpy->params.mki = NULL;
crypto_params_copy(&cpy->params, &cps->params, 1);

@ -1059,7 +1059,7 @@ decoder_t *decoder_new_fmtp(codec_def_t *def, int clockrate, int channels, int p
if (!def->codec_type)
goto err;
ret = g_slice_alloc0(sizeof(*ret));
ret = g_new0(__typeof(*ret), 1);
ret->def = def;
ret->clockrate_fact = def->default_clockrate_fact;
@ -1172,7 +1172,7 @@ void decoder_close(decoder_t *dec) {
decoder_switch_dtx(dec, -1);
resample_shutdown(&dec->resampler);
g_slice_free1(sizeof(*dec), dec);
g_free(dec);
}
@ -2065,7 +2065,7 @@ seq_ok:
encoder_t *encoder_new(void) {
encoder_t *ret = g_slice_alloc0(sizeof(*ret));
encoder_t *ret = g_new0(__typeof(*ret), 1);
format_init(&ret->requested_format);
format_init(&ret->actual_format);
ret->avpkt = av_packet_alloc();
@ -2243,7 +2243,7 @@ void encoder_free(encoder_t *enc) {
encoder_close(enc);
av_packet_free(&enc->avpkt);
resample_shutdown(&enc->resampler);
g_slice_free1(sizeof(*enc), enc);
g_free(enc);
}
static int avc_encoder_input(encoder_t *enc, AVFrame **frame) {
@ -4372,7 +4372,7 @@ static void evs_select_encoder_format(encoder_t *enc, format_t *req_format, cons
static const char *evs_decoder_init(decoder_t *dec, const str *extra_opts) {
dec->evs = g_slice_alloc0(evs_decoder_size);
dec->evs = g_malloc0(evs_decoder_size);
if (dec->in_format.clockrate != 48000)
ilog(LOG_WARN, "EVS: invalid decoder clock rate (%i) requested",
fraction_div(dec->in_format.clockrate, &dec->clockrate_fact));
@ -4386,7 +4386,7 @@ static const char *evs_decoder_init(decoder_t *dec, const str *extra_opts) {
}
static void evs_decoder_close(decoder_t *dec) {
evs_destroy_decoder(dec->evs);
g_slice_free1(evs_decoder_size, dec->evs);
g_free(dec->evs);
}
@ -4620,8 +4620,8 @@ static int evs_match_bitrate(int orig_br, unsigned int amr) {
static const char *evs_encoder_init(encoder_t *enc, const str *extra_opts) {
enc->evs.ctx = g_slice_alloc0(evs_encoder_size);
enc->evs.ind_list = g_slice_alloc(evs_encoder_ind_list_size);
enc->evs.ctx = g_malloc0(evs_encoder_size);
enc->evs.ind_list = g_malloc(evs_encoder_ind_list_size);
if (enc->requested_format.channels != 1)
ilog(LOG_WARN, "EVS: %i-channel EVS is not supported",
enc->requested_format.channels);
@ -4738,8 +4738,8 @@ static const char *evs_encoder_init(encoder_t *enc, const str *extra_opts) {
}
static void evs_encoder_close(encoder_t *enc) {
evs_destroy_encoder(enc->evs.ctx);
g_slice_free1(evs_encoder_size, enc->evs.ctx);
g_slice_free1(evs_encoder_ind_list_size, enc->evs.ind_list);
g_free(enc->evs.ctx);
g_free(enc->evs.ind_list);
}
@ -5335,7 +5335,7 @@ static void __codec_cc_free(codec_cc_t *c) {
}
av_packet_free(&c->avpkt);
av_packet_free(&c->avpkt_async);
g_slice_free1(sizeof(*c), c);
g_free(c);
}
@ -5711,7 +5711,7 @@ static codec_cc_t *codec_cc_new_sync(codec_def_t *src, format_t *src_format, cod
if (!pcma2opus_runner)
return NULL;
codec_cc_t *ret = g_slice_alloc0(sizeof(*ret));
codec_cc_t *ret = g_new0(__typeof(*ret), 1);
ret->pcma2opus.enc = cc_client_float2opus_new_ext(cc_client,
(codec_chain_opus_arguments) {
.bitrate = bitrate,
@ -5739,7 +5739,7 @@ static codec_cc_t *codec_cc_new_sync(codec_def_t *src, format_t *src_format, cod
if (!pcmu2opus_runner)
return NULL;
codec_cc_t *ret = g_slice_alloc0(sizeof(*ret));
codec_cc_t *ret = g_new0(__typeof(*ret), 1);
ret->pcmu2opus.enc = cc_client_float2opus_new_ext(cc_client,
(codec_chain_opus_arguments) {
.bitrate = bitrate,
@ -5768,7 +5768,7 @@ static codec_cc_t *codec_cc_new_sync(codec_def_t *src, format_t *src_format, cod
if (!pcma2g729a_runner)
return NULL;
codec_cc_t *ret = g_slice_alloc0(sizeof(*ret));
codec_cc_t *ret = g_new0(__typeof(*ret), 1);
ret->pcma2g729a.enc = cc_client_float2g729a_new(cc_client);
ret->clear = cc_float2g729a_clear;
ret->clear_arg = ret->pcma2g729a.enc;
@ -5792,7 +5792,7 @@ static codec_cc_t *codec_cc_new_sync(codec_def_t *src, format_t *src_format, cod
if (!pcmu2g729a_runner)
return NULL;
codec_cc_t *ret = g_slice_alloc0(sizeof(*ret));
codec_cc_t *ret = g_new0(__typeof(*ret), 1);
ret->pcmu2g729a.enc = cc_client_float2g729a_new(cc_client);
ret->clear = cc_float2g729a_clear;
ret->clear_arg = ret->pcmu2g729a.enc;
@ -5816,7 +5816,7 @@ static codec_cc_t *codec_cc_new_sync(codec_def_t *src, format_t *src_format, cod
if (!g729a2pcma_runner)
return NULL;
codec_cc_t *ret = g_slice_alloc0(sizeof(*ret));
codec_cc_t *ret = g_new0(__typeof(*ret), 1);
ret->g729a2pcma.dec = cc_client_g729a2float_new(cc_client);
ret->clear = cc_g729a2float_clear;
ret->clear_arg = ret->g729a2pcma.dec;
@ -5840,7 +5840,7 @@ static codec_cc_t *codec_cc_new_sync(codec_def_t *src, format_t *src_format, cod
if (!g729a2pcmu_runner)
return NULL;
codec_cc_t *ret = g_slice_alloc0(sizeof(*ret));
codec_cc_t *ret = g_new0(__typeof(*ret), 1);
ret->g729a2pcmu.dec = cc_client_g729a2float_new(cc_client);
ret->clear = cc_g729a2float_clear;
ret->clear_arg = ret->g729a2pcmu.dec;
@ -5863,7 +5863,7 @@ static codec_cc_t *codec_cc_new_sync(codec_def_t *src, format_t *src_format, cod
if (!opus2pcmu_runner)
return NULL;
codec_cc_t *ret = g_slice_alloc0(sizeof(*ret));
codec_cc_t *ret = g_new0(__typeof(*ret), 1);
ret->opus2pcmu.dec = cc_client_opus2float_new(cc_client);
ret->clear = cc_opus2float_clear;
ret->clear_arg = ret->opus2pcmu.dec;
@ -5886,7 +5886,7 @@ static codec_cc_t *codec_cc_new_sync(codec_def_t *src, format_t *src_format, cod
if (!opus2pcma_runner)
return NULL;
codec_cc_t *ret = g_slice_alloc0(sizeof(*ret));
codec_cc_t *ret = g_new0(__typeof(*ret), 1);
ret->opus2pcma.dec = cc_client_opus2float_new(cc_client);
ret->clear = cc_opus2float_clear;
ret->clear_arg = ret->opus2pcma.dec;
@ -5919,7 +5919,7 @@ static codec_cc_t *codec_cc_new_async(codec_def_t *src, format_t *src_format, co
if (!pcma2opus_async_runner)
return NULL;
codec_cc_t *ret = g_slice_alloc0(sizeof(*ret));
codec_cc_t *ret = g_new0(__typeof(*ret), 1);
ret->pcma2opus.enc = cc_client_float2opus_new_ext(cc_client,
(codec_chain_opus_arguments) {
.bitrate = bitrate,
@ -5953,7 +5953,7 @@ static codec_cc_t *codec_cc_new_async(codec_def_t *src, format_t *src_format, co
if (!pcmu2opus_async_runner)
return NULL;
codec_cc_t *ret = g_slice_alloc0(sizeof(*ret));
codec_cc_t *ret = g_new0(__typeof(*ret), 1);
ret->pcmu2opus.enc = cc_client_float2opus_new_ext(cc_client,
(codec_chain_opus_arguments) {
.bitrate = bitrate,
@ -5987,7 +5987,7 @@ static codec_cc_t *codec_cc_new_async(codec_def_t *src, format_t *src_format, co
if (!opus2pcmu_async_runner)
return NULL;
codec_cc_t *ret = g_slice_alloc0(sizeof(*ret));
codec_cc_t *ret = g_new0(__typeof(*ret), 1);
ret->opus2pcmu.dec = cc_client_opus2float_new(cc_client);
ret->clear = cc_opus2float_clear;
ret->clear_arg = ret->opus2pcmu.dec;
@ -6015,7 +6015,7 @@ static codec_cc_t *codec_cc_new_async(codec_def_t *src, format_t *src_format, co
if (!opus2pcma_async_runner)
return NULL;
codec_cc_t *ret = g_slice_alloc0(sizeof(*ret));
codec_cc_t *ret = g_new0(__typeof(*ret), 1);
ret->opus2pcma.dec = cc_client_opus2float_new(cc_client);
ret->clear = cc_opus2float_clear;
ret->clear_arg = ret->opus2pcma.dec;
@ -6043,7 +6043,7 @@ static codec_cc_t *codec_cc_new_async(codec_def_t *src, format_t *src_format, co
if (!pcma2g729a_async_runner)
return NULL;
codec_cc_t *ret = g_slice_alloc0(sizeof(*ret));
codec_cc_t *ret = g_new0(__typeof(*ret), 1);
ret->pcma2g729a.enc = cc_client_float2g729a_new(cc_client);
ret->clear = cc_float2g729a_clear;
ret->clear_arg = ret->pcma2g729a.enc;
@ -6071,7 +6071,7 @@ static codec_cc_t *codec_cc_new_async(codec_def_t *src, format_t *src_format, co
if (!pcmu2g729a_async_runner)
return NULL;
codec_cc_t *ret = g_slice_alloc0(sizeof(*ret));
codec_cc_t *ret = g_new0(__typeof(*ret), 1);
ret->pcmu2g729a.enc = cc_client_float2g729a_new(cc_client);
ret->clear = cc_float2g729a_clear;
ret->clear_arg = ret->pcmu2g729a.enc;
@ -6099,7 +6099,7 @@ static codec_cc_t *codec_cc_new_async(codec_def_t *src, format_t *src_format, co
if (!g729a2pcma_async_runner)
return NULL;
codec_cc_t *ret = g_slice_alloc0(sizeof(*ret));
codec_cc_t *ret = g_new0(__typeof(*ret), 1);
ret->g729a2pcma.dec = cc_client_g729a2float_new(cc_client);
ret->clear = cc_g729a2float_clear;
ret->clear_arg = ret->g729a2pcma.dec;
@ -6127,7 +6127,7 @@ static codec_cc_t *codec_cc_new_async(codec_def_t *src, format_t *src_format, co
if (!g729a2pcmu_async_runner)
return NULL;
codec_cc_t *ret = g_slice_alloc0(sizeof(*ret));
codec_cc_t *ret = g_new0(__typeof(*ret), 1);
ret->g729a2pcmu.dec = cc_client_g729a2float_new(cc_client);
ret->clear = cc_g729a2float_clear;
ret->clear_arg = ret->g729a2pcmu.dec;

@ -154,7 +154,7 @@ INLINE void *__obj_alloc(size_t size, void (*free_func)(void *)
) {
struct obj *r;
r = g_slice_alloc(size);
r = g_malloc(size);
__obj_init(r, size, free_func
#if OBJ_DEBUG
, type, file, func, line
@ -170,7 +170,7 @@ INLINE void *__obj_alloc0(size_t size, void (*free_func)(void *)
) {
struct obj *r;
r = g_slice_alloc0(size);
r = g_malloc0(size);
__obj_init(r, size, free_func
#if OBJ_DEBUG
, type, file, func, line
@ -245,7 +245,7 @@ INLINE void __obj_put(struct obj *o
free(o->type);
#endif
if (o->size != -1)
g_slice_free1(o->size, o);
g_free(o);
}

@ -51,7 +51,7 @@ static void poller_free_item(struct poller_item_int *ele) {
struct poller *poller_new(void) {
struct poller *p;
p = g_slice_alloc0(sizeof(*p));
p = g_new0(__typeof(*p), 1);
mutex_init(&p->lock);
p->fd = epoll_create1(0);
if (p->fd == -1)
@ -76,7 +76,7 @@ void poller_free(struct poller **pp) {
if (p->fd != -1)
close(p->fd);
p->fd = -1;
g_slice_free1(sizeof(*p), p);
g_free(p);
*pp = NULL;
}

@ -32,7 +32,7 @@ static ssize_t __fd_read(void *fd, void *b, size_t s) {
struct streambuf *streambuf_new_ptr(struct poller *p, void *fd_ptr, const struct streambuf_funcs *funcs) {
struct streambuf *b;
b = g_slice_alloc0(sizeof(*b));
b = g_new0(__typeof(*b), 1);
mutex_init(&b->lock);
b->buf = g_string_new("");
@ -50,7 +50,7 @@ struct streambuf *streambuf_new(struct poller *p, int fd) {
void streambuf_destroy(struct streambuf *b) {
g_string_free(b->buf, TRUE);
g_slice_free1(sizeof(*b), b);
g_free(b);
}

@ -404,7 +404,7 @@ static void closed(int fd, void *o) {
static void new_threads(uint num) {
while (num--) {
struct worker *w = g_slice_alloc0(sizeof(*w));
struct worker *w = g_new0(__typeof(*w), 1);
mutex_init(&w->comput_lock);
@ -433,7 +433,7 @@ static void kill_threads(uint num) {
while ((w = g_queue_pop_head(&to_join))) {
pthread_join(w->thr, NULL);
g_slice_free1(sizeof(*w), w);
g_free(w);
}
}
@ -1184,7 +1184,7 @@ TYPED_GQUEUE(stats, struct stats)
static void stats_queue_free(stats_q *q) {
struct stats *sp;
while ((sp = t_queue_pop_head(q)))
g_slice_free1(sizeof(*sp), sp);
g_free(sp);
t_queue_free(q);
}
@ -1231,7 +1231,7 @@ static bool cpu_collect(stats_q *outp, struct stats *totals) {
}
if (outp) {
struct stats *sp = g_slice_alloc(sizeof(*sp));
struct stats *sp = g_new(__typeof(*sp), 1);
*sp = stats;
t_queue_push_tail(outp, sp);
}
@ -1306,7 +1306,7 @@ static void delay_bar(const struct delay_stats *stats, int line, int x, int brea
static void other_thread_free(struct other_thread *thr) {
g_slice_free1(sizeof(*thr), thr);
g_free(thr);
}
static int pid_compare(const void *a, const void *b) {
@ -1361,7 +1361,7 @@ static int other_threads_collect(const bool do_output, int starty, int maxy, int
// object already exists?
struct other_thread *thr = g_hash_table_lookup(other_threads, GINT_TO_POINTER(pid));
if (!thr) {
thr = g_slice_alloc0(sizeof(*thr));
thr = g_new0(__typeof(*thr), 1);
g_hash_table_insert(other_threads, GINT_TO_POINTER(pid), thr);
}

@ -87,7 +87,7 @@ decode_t *decoder_new(const char *payload_str, const char *format, int ptime, ou
decoder_t *dec = decoder_new_fmtp(def, rtp_clockrate, channels, ptime, &out_format, NULL, &fmtp, NULL);
if (!dec)
return NULL;
decode_t *deco = g_slice_alloc0(sizeof(decode_t));
decode_t *deco = g_new0(decode_t, 1);
deco->dec = dec;
deco->mixer_idx = (unsigned int) -1;
return deco;
@ -209,5 +209,5 @@ void decoder_free(decode_t *deco) {
return;
decoder_close(deco->dec);
resample_shutdown(&deco->mix_resampler);
g_slice_free1(sizeof(*deco), deco);
g_free(deco);
}

@ -31,7 +31,7 @@ void garbage_add(void *ptr, free_func_t *free_func) {
// This is to make sure that all poller threads have left epoll_wait() after
// an fd has been removed from the watch list.
garbage_t *garb = g_slice_alloc(sizeof(*garb));
garbage_t *garb = g_new(garbage_t, 1);
garb->ptr = ptr;
garb->free_func = free_func;
@ -52,7 +52,7 @@ static void garbage_collect1(garbage_t *garb) {
garb->free_func(garb->ptr);
free(garb->wait_threads);
g_slice_free1(sizeof(*garb), garb);
g_free(garb);
}

@ -123,7 +123,7 @@ static void start_poller_thread(void) {
}
}
pthread_t *thr = g_slice_alloc(sizeof(*thr));
pthread_t *thr = g_new(__typeof(*thr), 1);
int ret = pthread_create(thr, NULL, poller_thread,
GUINT_TO_POINTER(garbage_new_thread_num()));
if (ret)
@ -138,7 +138,7 @@ static void wait_threads_finish(void) {
while ((thr = g_queue_pop_head(&threads))) {
pthread_cancel(*thr);
pthread_join(*thr, NULL);
g_slice_free1(sizeof(*thr), thr);
g_free(thr);
}
}

@ -46,7 +46,7 @@ static void meta_free(void *ptr) {
t_hash_table_destroy(mf->metadata_parsed);
g_ptr_array_free(mf->tags, TRUE);
g_ptr_array_free(mf->streams, TRUE);
g_slice_free1(sizeof(*mf), mf);
g_free(mf);
}
@ -273,7 +273,7 @@ static metafile_t *metafile_get(char *name) {
ilog(LOG_INFO, "New call for recording: '%s%s%s'", FMT_M(name));
mf = g_slice_alloc0(sizeof(*mf));
mf = g_new0(__typeof(*mf), 1);
mf->gsc = g_string_chunk_new(0);
mf->name = g_string_chunk_insert(mf->gsc, name);
pthread_mutex_init(&mf->lock, NULL);

@ -72,7 +72,7 @@ void mix_destroy(mix_t *mix) {
mix_shutdown(mix);
av_frame_free(&mix->sink_frame);
av_frame_free(&mix->silence_frame);
g_slice_free1(sizeof(*mix), mix);
g_free(mix);
}
void mix_set_channel_slots(mix_t *mix, unsigned int channel_slots) {
@ -250,7 +250,7 @@ err:
mix_t *mix_new(void) {
mix_t *mix = g_slice_alloc0(sizeof(*mix));
mix_t *mix = g_new0(mix_t, 1);
format_init(&mix->in_format);
format_init(&mix->out_format);
mix->sink_frame = av_frame_alloc();

@ -189,7 +189,7 @@ cleanup:
curl_slist_free_all(req->headers);
g_free(req->name);
g_free(req->full_filename_path);
g_slice_free1(sizeof(*req), req);
g_free(req);
}
@ -289,7 +289,7 @@ void notify_push_output(output_t *o, metafile_t *mf, tag_t *tag) {
if (!notify_threadpool)
return;
struct notif_req *req = g_slice_alloc0(sizeof(*req));
struct notif_req *req = g_new0(__typeof(*req), 1);
req->name = g_strdup(o->file_name);
req->full_filename_path = g_strdup_printf("%s.%s", o->full_filename, o->file_format);

@ -86,7 +86,7 @@ static void create_parent_dirs(char *dir) {
}
static output_t *output_alloc(const char *path, const char *name) {
output_t *ret = g_slice_alloc0(sizeof(*ret));
output_t *ret = g_new0(output_t, 1);
ret->file_path = g_strdup(path);
ret->file_name = g_strdup(name);
ret->full_filename = g_strdup_printf("%s/%s", path, name);
@ -424,7 +424,7 @@ void output_close(metafile_t *mf, output_t *output, tag_t *tag, bool discard) {
g_clear_pointer(&output->file_path, g_free);
g_clear_pointer(&output->file_name, g_free);
g_clear_pointer(&output->filename, g_free);
g_slice_free1(sizeof(*output), output);
g_free(output);
}

@ -80,7 +80,7 @@ static void packet_free(void *p) {
if (!packet)
return;
free(packet->buffer);
g_slice_free1(sizeof(*packet), packet);
g_free(packet);
}
@ -213,7 +213,7 @@ void ssrc_free(void *p) {
av_frame_free(&s->tls_silence_frame);
packet_sequencer_destroy(&s->sequencer);
ssrc_close(s);
g_slice_free1(sizeof(*s), s);
g_free(s);
}
// mf must be unlocked; returns ssrc locked
@ -228,7 +228,7 @@ static ssrc_t *ssrc_get(stream_t *stream, unsigned long ssrc) {
if (ret)
goto out;
ret = g_slice_alloc0(sizeof(*ret));
ret = g_new0(__typeof(*ret), 1);
pthread_mutex_init(&ret->lock, NULL);
ret->metafile = mf;
ret->stream = stream;
@ -378,7 +378,7 @@ static void ssrc_run(ssrc_t *ssrc) {
// stream is unlocked, buf is malloc'd
void packet_process(stream_t *stream, unsigned char *buf, unsigned len) {
packet_t *packet = g_slice_alloc0(sizeof(*packet));
packet_t *packet = g_new0(__typeof(*packet), 1);
packet->buffer = buf; // handing it over
// XXX more checking here

@ -34,7 +34,7 @@ void stream_close(stream_t *stream) {
}
void stream_free(stream_t *stream) {
g_slice_free1(sizeof(*stream), stream);
g_free(stream);
}
@ -101,7 +101,7 @@ static stream_t *stream_get(metafile_t *mf, unsigned long id) {
if (ret)
goto out;
ret = g_slice_alloc0(sizeof(*ret));
ret = g_new(stream_t, 1);
g_ptr_array_index(mf->streams, id) = ret;
pthread_mutex_init(&ret->lock, NULL);
ret->fd = -1;

@ -9,7 +9,7 @@ tag_t *tag_get(metafile_t *mf, unsigned long id) {
if (ret)
goto out;
ret = g_slice_alloc0(sizeof(*ret));
ret = g_new0(tag_t, 1);
g_ptr_array_index(mf->tags, id) = ret;
ret->id = id;
@ -34,5 +34,5 @@ void tag_metadata(metafile_t *mf, unsigned long t, const char *s) {
}
void tag_free(tag_t *tag) {
g_slice_free1(sizeof(*tag), tag);
g_free(tag);
}

Loading…
Cancel
Save