From 5681aa1f1633fe64feb385325c20a3f395db498f Mon Sep 17 00:00:00 2001 From: Yalu Zhang <yalu.zhang@iopsys.eu> Date: Tue, 20 Feb 2024 09:53:56 +0100 Subject: [PATCH] Repalce libc memory allocation and free functions with asterisk ones for easy debugging - calloc -> ast_calloc - free -> ast_free - malloc is not used currently --- src/channels/chan_voicemngr.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/channels/chan_voicemngr.c b/src/channels/chan_voicemngr.c index 973da86..5e03265 100644 --- a/src/channels/chan_voicemngr.c +++ b/src/channels/chan_voicemngr.c @@ -632,7 +632,7 @@ static void ubus_call_answer(struct ubus_request *req, int type, struct blob_att static void ubus_call_complete(struct ubus_request *req, int ret) { ast_verbose("%s() from thread %d\n", __func__, ast_get_tid()); - free(req); + ast_free(req); } static void endpt_signal(int line, char *signal, char *state, char *data) { @@ -654,7 +654,7 @@ static void endpt_signal(int line, char *signal, char *state, char *data) { if (data) blobmsg_add_string(&bb, "data", data); - req = calloc(1, sizeof(struct ubus_request)); + req = ast_calloc(1, sizeof(struct ubus_request)); if (!req) { blob_buf_free(&bb); return; @@ -665,7 +665,7 @@ static void endpt_signal(int line, char *signal, char *state, char *data) { if(res != UBUS_STATUS_OK) { ast_log(LOG_ERROR, "Error invoking method: %s %d\n", "signal", res); - free(req); + ast_free(req); blob_buf_free(&bb); return; } @@ -734,7 +734,7 @@ static void endpt_connection_data(int line, int id, const char *action, const st } } - req = calloc(1, sizeof(struct ubus_request)); + req = ast_calloc(1, sizeof(struct ubus_request)); if (!req) { blob_buf_free(&bb); return; @@ -744,7 +744,7 @@ static void endpt_connection_data(int line, int id, const char *action, const st if(res != UBUS_STATUS_OK) { ast_log(LOG_ERROR, "Error invoking method: %s %d\n", "connection", res); - free(req); + ast_free(req); blob_buf_free(&bb); return; } @@ -1003,7 +1003,7 @@ static int chan_voicemngr_indicate(struct ast_channel *ast, int condition, const } } sub->conference_initiator = 0; - free(sub->conference_id); + ast_free(sub->conference_id); sub->conference_id = NULL; res = 0; @@ -1607,7 +1607,7 @@ static int chan_voicemngr_hangup(struct ast_channel *ast) memset(p->ext, 0, sizeof(p->ext)); sub->owner = NULL; sub->conference_initiator = 0; - free(sub->conference_id); + ast_free(sub->conference_id); sub->conference_id = NULL; sub->sip_client_id = -1; ast_module_unref(ast_module_info->self); @@ -1770,7 +1770,7 @@ static int chan_voicemngr_write(struct ast_channel *ast, struct ast_frame *frame /*packet_size = sizeof(audio_packet_t) - 1 + RTP_HEADER_SIZE + frame->datalen; CNG paket has only 1 data for the noise lvl, datalen=1*/ packet_size = sizeof(audio_packet_t) + RTP_HEADER_SIZE ; - ap = calloc(1, packet_size); + ap = ast_calloc(1, packet_size); if (!ap) { ast_log(LOG_ERROR, "Out of memory\n"); return -1; @@ -1802,12 +1802,12 @@ static int chan_voicemngr_write(struct ast_channel *ast, struct ast_frame *frame //ast_mutex_unlock(&sub->parent->lock); pvt_unlock(sub->parent); pe_bus_send(audio_tx_bus, (uint8_t *)ap, packet_size); - free(ap); + ast_free(ap); } if(frame->frametype == AST_FRAME_VOICE) { packet_size = sizeof(audio_packet_t) - 1 + RTP_HEADER_SIZE + frame->datalen; - ap = calloc(1, packet_size); + ap = ast_calloc(1, packet_size); if (!ap) { ast_log(LOG_ERROR, "Out of memory\n"); return -1; @@ -1846,12 +1846,12 @@ static int chan_voicemngr_write(struct ast_channel *ast, struct ast_frame *frame chan_voicemngr_modify_codec(sub); //in case of early media on outgoing pe_bus_send(audio_tx_bus, (uint8_t *)ap, packet_size); - free(ap); + ast_free(ap); } if(frame->frametype == AST_FRAME_RTCP) { packet_size = sizeof(audio_packet_t) - 1 + frame->datalen; - ap = calloc(1, packet_size); + ap = ast_calloc(1, packet_size); if (!ap) { ast_log(LOG_ERROR, "Out of memory\n"); return -1; @@ -1867,7 +1867,7 @@ static int chan_voicemngr_write(struct ast_channel *ast, struct ast_frame *frame chan_voicemngr_process_incoming_rtcp_packet(sub, ap->rtp, ap->rtp_size); pe_bus_send(audio_tx_bus, (uint8_t *)ap, packet_size); - free(ap); + ast_free(ap); } return 0; } @@ -4391,7 +4391,7 @@ static int unload_module(void) ast_mutex_lock(&p->lock); } } - free(registration_change_sub); + ast_free(registration_change_sub); registration_change_sub = NULL; pvt_unlock(p); //ast_mutex_unlock(&p->lock); @@ -5265,7 +5265,7 @@ static int load_module(void) goto err; } - registration_change_sub = calloc(num_endpoints, sizeof(struct stasis_subscription *)); + registration_change_sub = ast_calloc(num_endpoints, sizeof(struct stasis_subscription *)); /* Setup scheduler thread */ if (!(sched = ast_sched_context_create())) { -- GitLab