当前位置: 首页>>代码示例>>C++>>正文


C++ TSK_OBJECT_SAFE_FREE函数代码示例

本文整理汇总了C++中TSK_OBJECT_SAFE_FREE函数的典型用法代码示例。如果您正苦于以下问题:C++ TSK_OBJECT_SAFE_FREE函数的具体用法?C++ TSK_OBJECT_SAFE_FREE怎么用?C++ TSK_OBJECT_SAFE_FREE使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了TSK_OBJECT_SAFE_FREE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _tcomp_result_reset

/**Resets the result.
*/
void _tcomp_result_reset(tcomp_result_t *result, tsk_bool_t isDestructor, tsk_bool_t isResetOutput)
{
	if(result){
		uint8_t i;
		for(i = 0; i < result->statesToCreateIndex; i++){
			TSK_OBJECT_SAFE_FREE(result->statesToCreate[i]);
		}

		for(i = 0; i < result->statesToFreeIndex; i++){
			TSK_OBJECT_SAFE_FREE(result->statesToFree[i]);
		}

		if(!isDestructor){
			result->statesToCreateIndex = 0;
			result->statesToFreeIndex = 0;
			result->consumed_cycles = 0;

			tcomp_params_reset(result->remote_parameters);
			
			if(isResetOutput){
				tcomp_buffer_reset(result->output_buffer);
			}
			
			tcomp_reqfeed_reset(result->req_feedback);
			tcomp_buffer_freeBuff(result->ret_feedback);

			result->isNack = 0;
			tcomp_buffer_freeBuff(result->nack_info);
		}
	}
	else{
		TSK_DEBUG_ERROR("NULL SigComp result.");
	}
}
开发者ID:NewComerBH,项目名称:doubango,代码行数:36,代码来源:tcomp_result.c

示例2: tnet_tls_socket_create

tnet_tls_socket_handle_t* tnet_tls_socket_create(tnet_fd_t fd, struct ssl_ctx_st* ssl_ctx)
{
#if !HAVE_OPENSSL
	TSK_DEBUG_ERROR("OpenSSL not enabled");
	return tsk_null;
#else
	tnet_tls_socket_t* socket;
	if(fd <= 0 || !ssl_ctx){
		TSK_DEBUG_ERROR("Invalid parameter");
		return tsk_null;
	}
	if((socket = tsk_object_new(tnet_tls_socket_def_t))){
		socket->fd = fd;
		if(!(socket->ssl = SSL_new(ssl_ctx))){
			TSK_DEBUG_ERROR("SSL_new(CTX) failed [%s]", ERR_error_string(ERR_get_error(), tsk_null));
			TSK_OBJECT_SAFE_FREE(socket);
			return tsk_null;
		}
		if(SSL_set_fd(socket->ssl, socket->fd) != 1){
			TSK_DEBUG_ERROR("SSL_set_fd(%d) failed [%s]", socket->fd, ERR_error_string(ERR_get_error(), tsk_null));
			TSK_OBJECT_SAFE_FREE(socket);
			return tsk_null;
		}
	}
	return socket;
#endif
}
开发者ID:NewComerBH,项目名称:doubango,代码行数:27,代码来源:tnet_tls.c

示例3: tnet_transport_create

tnet_transport_t* tnet_transport_create(const char* host, tnet_port_t port, tnet_socket_type_t type, const char* description)
{		
	tnet_transport_t* transport;

	if((transport = tsk_object_new(tnet_transport_def_t))){
		transport->description = tsk_strdup(description);
		transport->local_host = tsk_strdup(host);
		transport->req_local_port = port;
		transport->type = type;
		transport->context = tnet_transport_context_create();
		
		if((transport->master = tnet_socket_create(transport->local_host, transport->req_local_port, transport->type))){
			transport->local_ip = tsk_strdup(transport->master->ip);
			transport->bind_local_port = transport->master->port;
		}
		else{
			TSK_DEBUG_ERROR("Failed to create master socket");
			TSK_OBJECT_SAFE_FREE(transport);
		}

		if(_tnet_transport_ssl_init(transport) != 0){
			TSK_DEBUG_ERROR("Failed to initialize TLS and/or DTLS caps");
			TSK_OBJECT_SAFE_FREE(transport);
		}
		// set priority
		tsk_runnable_set_priority(TSK_RUNNABLE(transport), TSK_THREAD_PRIORITY_TIME_CRITICAL);
	}

	return transport;
}
开发者ID:bizzr3,项目名称:webrtc2sip-1,代码行数:30,代码来源:tnet_transport.c

示例4: tnet_transport_dtor

static tsk_object_t* tnet_transport_dtor(tsk_object_t * self)
{
    tnet_transport_t *transport = self;
    if (transport){
        tnet_transport_set_callback(transport, tsk_null, tsk_null);
        tnet_transport_shutdown(transport);
        TSK_OBJECT_SAFE_FREE(transport->master);
        TSK_OBJECT_SAFE_FREE(transport->context);
        TSK_OBJECT_SAFE_FREE(transport->natt_ctx);
        TSK_FREE(transport->local_ip);
        TSK_FREE(transport->local_host);
        
        // proxy
        TSK_OBJECT_SAFE_FREE(transport->proxy.info);
        
        // (tls and dtls) = ssl
        TSK_FREE(transport->tls.ca);
        TSK_FREE(transport->tls.pbk);
        TSK_FREE(transport->tls.pvk);
        _tnet_transport_ssl_deinit(transport); // openssl contexts
        
        TSK_DEBUG_INFO("*** Transport (%s) destroyed ***", transport->description);
        TSK_FREE(transport->description);
    }
    
    return self;
}
开发者ID:gufengyeying,项目名称:doubango,代码行数:27,代码来源:tnet_transport.c

示例5: tnet_dtls_socket_create

tnet_dtls_socket_handle_t* tnet_dtls_socket_create(struct tnet_socket_s* wrapped_sock, struct ssl_ctx_st* ssl_ctx)
{
#if !HAVE_OPENSSL || !HAVE_OPENSSL_DTLS
	TSK_DEBUG_ERROR("OpenSSL or DTLS not enabled");
	return tsk_null;
#else
	tnet_dtls_socket_t* socket;

	if (!wrapped_sock || !ssl_ctx){
		TSK_DEBUG_ERROR("Invalid parameter");
		return tsk_null;
	}
	if ((socket = tsk_object_new(tnet_dtls_socket_def_t))) {
		const tsk_bool_t set_mtu = TNET_SOCKET_TYPE_IS_DGRAM(wrapped_sock->type) || 1; //!\ This is required even if the local transport is TCP/TLS because the relayed (TURN) transport could be UDP
		socket->wrapped_sock = tsk_object_ref(wrapped_sock);
		if (!(socket->ssl = SSL_new(ssl_ctx))) {
			TSK_DEBUG_ERROR("SSL_new(CTX) failed [%s]", ERR_error_string(ERR_get_error(), tsk_null));
			TSK_OBJECT_SAFE_FREE(socket);
			return tsk_null;
		}
		if (set_mtu) {
			SSL_set_options(socket->ssl, SSL_OP_NO_QUERY_MTU);
			SSL_set_mtu(socket->ssl, TNET_DTLS_MTU - 28);
			socket->ssl->d1->mtu = TNET_DTLS_MTU - 28;
		}
		if (!(socket->rbio = BIO_new(BIO_s_mem())) || !(socket->wbio = BIO_new(BIO_s_mem()))){
			TSK_DEBUG_ERROR("BIO_new_socket(%d) failed [%s]", socket->wrapped_sock->fd, ERR_error_string(ERR_get_error(), tsk_null));
			if (socket->rbio){
				BIO_free(socket->rbio);
			}
			if (socket->wbio){
				BIO_free(socket->wbio);
			}
			TSK_OBJECT_SAFE_FREE(socket);
			return tsk_null;
		}
		BIO_set_mem_eof_return(socket->rbio, -1);
		BIO_set_mem_eof_return(socket->wbio, -1);
		SSL_set_bio(socket->ssl, socket->rbio, socket->wbio);
		SSL_set_mode(socket->ssl, SSL_MODE_AUTO_RETRY);
		SSL_set_read_ahead(socket->ssl, 1);
		if (set_mtu) {
			BIO_ctrl(SSL_get_wbio(socket->ssl), BIO_CTRL_DGRAM_SET_MTU, TNET_DTLS_MTU - 28, NULL);
		}

		if ((socket->verify_peer = (SSL_CTX_get_verify_mode(ssl_ctx) != SSL_VERIFY_NONE))){
			TSK_DEBUG_INFO("SSL cert verify: ON");
			socket->verify_peer = tsk_true;
			SSL_set_verify(socket->ssl, (SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT), _tnet_dtls_verify_cert);
		}
		else {
			TSK_DEBUG_ERROR("Verity not enabled");
		}

		SSL_set_app_data(socket->ssl, socket);
	}
	return socket;
#endif
}
开发者ID:NewComerBH,项目名称:doubango,代码行数:59,代码来源:tnet_dtls.c

示例6: tsdp_ctx_destroy

static void* tsdp_ctx_destroy(void * self)
{ 
	tsdp_ctx_t *ctx = self;
	if(ctx){
		TSK_OBJECT_SAFE_FREE(ctx->local);
		TSK_OBJECT_SAFE_FREE(ctx->remote);
		TSK_OBJECT_SAFE_FREE(ctx->negotiated);
	}
	return self;
}
开发者ID:yhp920116,项目名称:YunTong,代码行数:10,代码来源:tsdp.c

示例7: tsms_tpdu_deliver_dtor

static tsk_object_t* tsms_tpdu_deliver_dtor(tsk_object_t * self)
{ 
	tsms_tpdu_deliver_t *deliver = self;
	if(deliver){
		/*deinit base*/
		tsms_tpdu_message_deinit(TSMS_TPDU_MESSAGE(deliver));
		/*deinit self*/
		TSK_OBJECT_SAFE_FREE(deliver->oa);
		TSK_OBJECT_SAFE_FREE(deliver->smsc);
	}
	return self;
}
开发者ID:NewComerBH,项目名称:doubango,代码行数:12,代码来源:tsms_tpdu_deliver.c

示例8: thttp_action_dtor

static tsk_object_t* thttp_action_dtor(tsk_object_t * self)
{ 
	thttp_action_t *action = self;
	if(action){
		TSK_FREE(action->url);
		TSK_FREE(action->method);

		TSK_OBJECT_SAFE_FREE(action->options);
		TSK_OBJECT_SAFE_FREE(action->headers);
		TSK_OBJECT_SAFE_FREE(action->payload);
	}

	return self;
}
开发者ID:NewComerBH,项目名称:doubango,代码行数:14,代码来源:thttp_action.c

示例9: tmsrp_receiver_dtor

static void* tmsrp_receiver_dtor(tsk_object_t * self)
{ 
	tmsrp_receiver_t *receiver = self;
	if(receiver){
		/* Stop */
		tmsrp_receiver_stop(receiver);

		TSK_OBJECT_SAFE_FREE(receiver->config);
		TSK_OBJECT_SAFE_FREE(receiver->data_in);
		TSK_OBJECT_SAFE_FREE(receiver->buffer);
		// the FD is owned by the transport ...do not close it
	}
	return self;
}
开发者ID:NewComerBH,项目名称:doubango,代码行数:14,代码来源:tmsrp_receiver.c

示例10: tnet_transport_unprepare

int tnet_transport_unprepare(tnet_transport_t *transport)
{
    int ret = -1;
    transport_context_t *context;

    if (!transport || !transport->context) {
        TSK_DEBUG_ERROR("Invalid parameter.");
        return -1;
    }
    else {
        context = transport->context;
    }

    if (!transport->prepared) {
        return 0;
    }

    transport->prepared = tsk_false;

    while (context->count) {
        removeSocket(0, context); // safe
    }
    // destroy master as it has been close by removeSocket()
    TSK_OBJECT_SAFE_FREE(transport->master);

    return 0;
}
开发者ID:CoderIvanLee,项目名称:doubango,代码行数:27,代码来源:tnet_transport_win32.c

示例11: tnet_dtls_socket_dtor

static tsk_object_t* tnet_dtls_socket_dtor(tsk_object_t * self)
{
	tnet_dtls_socket_t *socket = self;
	if (socket){
#if HAVE_OPENSSL
		if (socket->rbio) {
			//BIO_free(socket->rbio);
			socket->rbio = tsk_null;
		}
		if (socket->wbio) {
			//BIO_free(socket->wbio);
			socket->wbio = tsk_null;
		}
		if (socket->ssl) {
			SSL_shutdown(socket->ssl);
			// https://www.openssl.org/docs/crypto/BIO_s_bio.html
			// implicitly frees internal_bio
			SSL_free(socket->ssl);
		}
#endif
		TSK_FREE(socket->handshake_data.ptr);
		TSK_OBJECT_SAFE_FREE(socket->wrapped_sock);
		tsk_safeobj_deinit(socket);

		TSK_DEBUG_INFO("*** tnet_dtls_socket_t destroyed ***");
	}
	return self;
}
开发者ID:NewComerBH,项目名称:doubango,代码行数:28,代码来源:tnet_dtls.c

示例12: tmsrp_data_out_get

tsk_buffer_t* tmsrp_data_out_get(tmsrp_data_out_t* self)
{
	tsk_buffer_t* ret = tsk_null;
	tsk_size_t toread;

	if(!self){
		return tsk_null;
	}
	
	if(!(toread = self->size > TMSRP_MAX_CHUNK_SIZE ? TMSRP_MAX_CHUNK_SIZE : self->size)){
		return tsk_null;
	}

	if(self->message){
		ret = tsk_buffer_create(TSK_BUFFER_DATA(self->message), toread);
		tsk_buffer_remove(self->message, 0, toread);
		self->size = self->message->size;
	}
	else if(self->file){
		// Buffer hack
		tsk_size_t read;
		ret = tsk_buffer_create_null();
		ret->data = tsk_calloc(toread, sizeof(uint8_t));
		ret->size = toread;
		if((read = fread(ret->data, sizeof(uint8_t), toread, self->file)) == toread){
			self->size -= toread;
		}
		else{
			TSK_OBJECT_SAFE_FREE(ret);
		}
	}
	

	return ret;
}
开发者ID:SayCV,项目名称:doubango,代码行数:35,代码来源:tmsrp_data.c

示例13: tdav_consumer_audio_set_jitterbuffer

void tdav_consumer_audio_set_jitterbuffer(tdav_consumer_audio_t* self, struct tmedia_jitterbuffer_s* jitterbuffer)
{
	tsk_safeobj_lock(self);
	TSK_OBJECT_SAFE_FREE(self->jitterbuffer);
	self->jitterbuffer = (struct tmedia_jitterbuffer_s*)tsk_object_ref(jitterbuffer);
	tsk_safeobj_unlock(self);
}
开发者ID:bizzr3,项目名称:webrtc2sip-1,代码行数:7,代码来源:tdav_consumer_audio.c

示例14: tsip_action_dtor

static tsk_object_t* tsip_action_dtor(tsk_object_t * self)
{ 
	tsip_action_t *action = self;
	if(action){
		TSK_OBJECT_SAFE_FREE(action->headers);
		TSK_OBJECT_SAFE_FREE(action->payload);

		TSK_OBJECT_SAFE_FREE(action->media.params);

		TSK_FREE(action->line_resp.phrase);

		TSK_FREE(action->ect.to);
	}

	return self;
}
开发者ID:SayCV,项目名称:doubango,代码行数:16,代码来源:tsip_action.c

示例15: tsip_header_Authorization_create

tsip_header_Authorization_t *tsip_header_Authorization_parse(const char *data, tsk_size_t size)
{
	tsip_header_Authorization_t *hdr_sip = 0;
	thttp_header_Authorization_t* hdr_http;

	if((hdr_http = thttp_header_Authorization_parse(data, size))){
		hdr_sip = tsip_header_Authorization_create();
		
		hdr_sip->scheme = tsk_strdup(hdr_http->scheme);
		hdr_sip->username = tsk_strdup(hdr_http->username);
		hdr_sip->realm =  tsk_strdup(hdr_http->realm);
		hdr_sip->nonce =  tsk_strdup(hdr_http->nonce);
		hdr_sip->uri =  tsk_strdup(hdr_http->uri);
		hdr_sip->response =  tsk_strdup(hdr_http->response);
		hdr_sip->algorithm =  tsk_strdup(hdr_http->algorithm);
		hdr_sip->cnonce =  tsk_strdup(hdr_http->cnonce);
		hdr_sip->opaque =  tsk_strdup(hdr_http->opaque);
		hdr_sip->qop =  tsk_strdup(hdr_http->qop);
		hdr_sip->nc =  tsk_strdup(hdr_http->nc);

		TSIP_HEADER(hdr_sip)->params = tsk_object_ref(THTTP_HEADER(hdr_http)->params);

		TSK_OBJECT_SAFE_FREE(hdr_http);
	}
	
	return hdr_sip;
}
开发者ID:NewComerBH,项目名称:doubango,代码行数:27,代码来源:tsip_header_Authorization.c


注:本文中的TSK_OBJECT_SAFE_FREE函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。