diff --git a/coreapi/bellesip_sal/sal_impl.c b/coreapi/bellesip_sal/sal_impl.c index 49f6fa792..7abf624b6 100644 --- a/coreapi/bellesip_sal/sal_impl.c +++ b/coreapi/bellesip_sal/sal_impl.c @@ -347,6 +347,7 @@ static void process_transaction_terminated(void *user_ctx, const belle_sip_trans } if (op) sal_op_unref(op); /*no longuer need to ref op*/ } + static void process_auth_requested(void *sal, belle_sip_auth_event_t *auth_event) { SalAuthInfo auth_info; memset(&auth_info,0,sizeof(SalAuthInfo)); @@ -358,9 +359,10 @@ static void process_auth_requested(void *sal, belle_sip_auth_event_t *auth_event belle_sip_auth_event_set_userid(auth_event,(const char*)auth_info.userid); return; } + Sal * sal_init(){ char stack_string[64]; - belle_sip_listener_t* listener; + belle_sip_listener_callbacks_t listener_callbacks; Sal * sal=ms_new0(Sal,1); sal->nat_helper_enabled=TRUE; snprintf(stack_string,sizeof(stack_string)-1,"(belle-sip/%s)",belle_sip_version_to_string()); @@ -374,15 +376,16 @@ Sal * sal_init(){ belle_sip_set_log_handler(_belle_sip_log); sal->stack = belle_sip_stack_new(NULL); sal->prov = belle_sip_stack_create_provider(sal->stack,NULL); - sal->listener_callbacks.process_dialog_terminated=process_dialog_terminated; - sal->listener_callbacks.process_io_error=process_io_error; - sal->listener_callbacks.process_request_event=process_request_event; - sal->listener_callbacks.process_response_event=process_response_event; - sal->listener_callbacks.process_timeout=process_timeout; - sal->listener_callbacks.process_transaction_terminated=process_transaction_terminated; - sal->listener_callbacks.process_auth_requested=process_auth_requested; - belle_sip_provider_add_sip_listener(sal->prov,listener=belle_sip_listener_create_from_callbacks(&sal->listener_callbacks,sal)); - /* belle_sip_callbacks_t is unowned, why ?belle_sip_object_unref(listener);*/ + memset(&listener_callbacks,0,sizeof(listener_callbacks)); + listener_callbacks.process_dialog_terminated=process_dialog_terminated; + listener_callbacks.process_io_error=process_io_error; + listener_callbacks.process_request_event=process_request_event; + listener_callbacks.process_response_event=process_response_event; + listener_callbacks.process_timeout=process_timeout; + listener_callbacks.process_transaction_terminated=process_transaction_terminated; + listener_callbacks.process_auth_requested=process_auth_requested; + sal->listener=belle_sip_listener_create_from_callbacks(&listener_callbacks,sal); + belle_sip_provider_add_sip_listener(sal->prov,sal->listener); return sal; } void sal_set_user_pointer(Sal *sal, void *user_data){ @@ -443,6 +446,7 @@ void sal_uninit(Sal* sal){ belle_sip_object_unref(sal->user_agent); belle_sip_object_unref(sal->prov); belle_sip_object_unref(sal->stack); + belle_sip_object_unref(sal->listener); ms_free(sal); return ; }; diff --git a/coreapi/bellesip_sal/sal_impl.h b/coreapi/bellesip_sal/sal_impl.h index e7e22b9b2..13b04fe7f 100644 --- a/coreapi/bellesip_sal/sal_impl.h +++ b/coreapi/bellesip_sal/sal_impl.h @@ -29,17 +29,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. struct Sal{ SalCallbacks callbacks; MSList *pending_auths;/*MSList of SalOp */ - belle_sip_listener_callbacks_t listener_callbacks; belle_sip_stack_t* stack; belle_sip_provider_t *prov; belle_sip_header_user_agent_t* user_agent; + belle_sip_listener_t *listener; void *up; /*user pointer*/ int session_expires; - bool_t one_matching_codec; unsigned int keep_alive; + bool_t one_matching_codec; bool_t use_tcp_tls_keep_alive; bool_t nat_helper_enabled; - }; typedef enum SalOpSate { @@ -74,7 +73,7 @@ struct SalOp{ SalOpSate_t state; SalOpDir_t dir; belle_sip_refresher_t* refresher; - unsigned int ref; + int ref; }; belle_sdp_session_description_t * media_description_to_sdp(const SalMediaDescription *sal); diff --git a/coreapi/proxy.c b/coreapi/proxy.c index 1094f10f4..760f5961f 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -86,6 +86,7 @@ void linphone_proxy_config_destroy(LinphoneProxyConfig *obj){ if (obj->dial_prefix!=NULL) ms_free(obj->dial_prefix); if (obj->op) sal_op_release(obj->op); if (obj->publish_op) sal_op_release(obj->publish_op); + ms_free(obj); } /** diff --git a/coreapi/sal.c b/coreapi/sal.c index 4685b0bc5..3a6a6b5c0 100644 --- a/coreapi/sal.c +++ b/coreapi/sal.c @@ -287,7 +287,7 @@ void sal_op_set_route(SalOp *op, const char *route){ route_string=sal_address_as_string((SalAddress*)op_base->route_addresses->data); \ } assign_string(&op_base->route,route_string); \ - if(route_string) ortp_free(route_string); + if(route_string) ms_free(route_string); } const MSList* sal_op_get_route_addresses(const SalOp *op) { return ((SalOpBase*)op)->route_addresses; @@ -395,6 +395,25 @@ void __sal_op_set_network_origin_address(SalOp *op, SalAddress *origin){ void __sal_op_free(SalOp *op){ SalOpBase *b=(SalOpBase *)op; + if (b->from_address){ + sal_address_destroy(b->from_address); + b->from_address=NULL; + } + if (b->to_address){ + sal_address_destroy(b->to_address); + b->to_address=NULL; + } + + if (b->service_route){ + sal_address_destroy(b->service_route); + b->service_route=NULL; + } + + if (b->origin_address){ + sal_address_destroy(b->origin_address); + b->origin_address=NULL; + } + if (b->from) { ms_free(b->from); b->from=NULL; @@ -438,6 +457,10 @@ void __sal_op_free(SalOp *op){ if (b->service_route) { sal_address_destroy(b->service_route); } + if (b->route_addresses){ + ms_list_for_each(b->route_addresses,(void (*)(void*)) sal_address_destroy); + b->route_addresses=ms_list_free(b->route_addresses); + } if (b->custom_headers) sal_custom_header_free(b->custom_headers); ms_free(op);