• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ HK函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: addrs_count

static ssize_t addrs_count(backend_t *chain, request_t *request){
	size_t           units; 
	data_t          *buffer;
	data_ctx_t      *buffer_ctx;
	file_userdata   *data = ((file_userdata *)chain->userdata);
	
	if( (buffer = hash_get_data(request, HK(buffer))) == NULL)
		return -EINVAL;
	
	buffer_ctx = hash_get_data_ctx(request, HK(buffer));
	
	if(hash_find(request, HK(blocks)) == NULL){
		if(tree_size(data->tree, &units) != 0)
			return -EINVAL;
	}else{
		units = tree_blocks_count(data->tree);
	}
	
	data_t dt_units = DATA_PTR_OFFT(&units);
	
	return data_transfer(
		buffer,     buffer_ctx,
		&dt_units,  NULL
	);
}
开发者ID:imaxxs,项目名称:frozen,代码行数:25,代码来源:blocks_addressing.c


示例2: mphf_configure_any

static ssize_t          mphf_configure_any(backend_t *backend, config_t *config, request_t *fork_req){ // {{{
	ssize_t          ret;
	uintmax_t        fork_only       = 0;
	char            *mphf_type_str   = NULL;
	mphf_userdata   *userdata        = (mphf_userdata *)backend->userdata;
	
	hash_data_copy(ret, TYPE_STRINGT,  mphf_type_str,    config, HK(type));
	hash_data_copy(ret, TYPE_UINTT,    fork_only,        config, HK(fork_only));
	hash_data_copy(ret, TYPE_HASHKEYT, userdata->input,  config, HK(input));
	hash_data_copy(ret, TYPE_HASHKEYT, userdata->output, config, HK(output));
       
	if(fork_only == 1 && fork_req == NULL)
		return 0;

	if( (userdata->mphf_proto = mphf_string_to_proto(mphf_type_str)) == NULL)
		return error("backend mphf parameter mphf_type invalid or not supplied");
	
	memset(&userdata->mphf, 0, sizeof(userdata->mphf));
	
	userdata->mphf.config     = config;
	userdata->broken          = 0;

	if(fork_req == NULL){
		if( (ret = userdata->mphf_proto->func_load(&userdata->mphf)) < 0)
			return ret;
	}else{
		if( (ret = userdata->mphf_proto->func_fork(&userdata->mphf, fork_req)) < 0)
			return ret;
	}
	return 0;
} // }}}
开发者ID:hyperation,项目名称:frozen,代码行数:31,代码来源:mphf.c


示例3: action_crud_to_fast

ssize_t     action_crud_to_fast(void *userdata, request_t *request, f_hash_to_fast callback){ // {{{
	ssize_t                ret;
	action_t               action;
	data_t                *key;
	data_t                *value;
	
	hash_data_get(ret, TYPE_ACTIONT, action, request, HK(action));
	if(ret != 0)
		return ret;
	
	key   = hash_data_find(request, HK(key));
	value = hash_data_find(request, HK(value));
	
	if(key){
		data_realholder(ret, key, key);
		if(ret < 0)
			return ret;
	}
	if(value){
		data_realholder(ret, value, value);
		if(ret < 0)
			return ret;
	}
	
	fastcall_crud fargs = { { 4, action }, key, value };
	ret = callback(userdata, &fargs);
	
	return ret;
} // }}}
开发者ID:samuell,项目名称:frozen,代码行数:29,代码来源:api.c


示例4: action_write_to_fast

ssize_t     action_write_to_fast(void *userdata, request_t *request, f_hash_to_fast callback){ // {{{
	ssize_t                ret;
	data_t                *r_buffer;
	data_t                *r_size;
	uintmax_t              offset            = 0;
	uintmax_t              size              = ~0;
	
	hash_data_get(ret, TYPE_UINTT, offset, request, HK(offset));
	
	if( (r_size   = hash_data_find(request, HK(size))) != NULL){
		data_get(ret, TYPE_UINTT, size, r_size);
	}
	
	if( (r_buffer = hash_data_find(request, HK(buffer))) == NULL)
		return -EINVAL;
	
	data_t                 d_slice    = DATA_SLICET(userdata, offset, size); // FIXME
	fastcall_convert_to    r_convert = { { 5, ACTION_CONVERT_TO }, &d_slice, FORMAT(native) };
	
	ret = data_query(r_buffer, &r_convert);
	
	fastcall_write         r_write           = { { 5, ACTION_WRITE }, 0, &r_convert.transfered, sizeof(r_convert.transfered) };
	if(r_size)
		data_query(r_size, &r_write);
	
	return ret;
} // }}}
开发者ID:samuell,项目名称:frozen,代码行数:27,代码来源:api.c


示例5: action_crud_to_hash

ssize_t     action_crud_to_hash(void *userdata, fastcall_crud *fargs, f_fast_to_hash callback){ // {{{
	ssize_t                ret;
	
	request_t  r_next[] = {
		{ HK(action),     DATA_PTR_ACTIONT( &fargs->header.action            ) },
		hash_null,
		hash_null,
		hash_end
	};
	if(fargs->key){
		r_next[1].key  = HK(key);
		r_next[1].data = *fargs->key;
	}
	if(fargs->value){
		r_next[2].key  = HK(value);
		r_next[2].data = *fargs->value;
	}
	ret = callback(userdata, r_next);
	
	if(fargs->key)
		*fargs->key   = r_next[1].data;
	if(fargs->value)
		*fargs->value = r_next[2].data;
	return ret;
} // }}}
开发者ID:samuell,项目名称:frozen,代码行数:25,代码来源:api.c


示例6: data_triplet_format_t_from_config

static ssize_t data_triplet_format_t_from_config(data_t *data, config_t *config) { // {{{
    ssize_t                ret;
    data_t                 storage;
    data_t                 slave;

    hash_holder_consume(ret, storage, config, HK(data));
    if(ret < 0)
        goto error1;

    hash_holder_consume(ret, slave,   config, HK(slave));
    if(ret < 0)
        goto error2;

    if( (ret = data_triplet_format_t(data, storage, slave)) < 0)
        goto error3;

    return 0;

error3:
    data_free(&slave);
error2:
    data_free(&storage);
error1:
    return ret;
} // }}}
开发者ID:samuell,项目名称:frozen,代码行数:25,代码来源:triplet_format_t.c


示例7: addrs_configure

static int addrs_configure(backend_t *chain, hash_t *config){
	ssize_t           ret;
	DT_UINT32T          elements_per_level = 0;
	DT_UINT32T          read_per_calc      = READ_PER_CALC_DEFAULT;
	addrs_userdata   *data = (addrs_userdata *)chain->userdata;
	
	hash_data_copy(ret, TYPE_UINT32T, elements_per_level, config, HK(perlevel));
	hash_data_copy(ret, TYPE_UINT32T, read_per_calc,      config, HK(read_size));
	
	if(elements_per_level <= 1)
		return -EINVAL; // "chain blocks-address variable 'per-level' invalid");
	
	if(read_per_calc < 1)
		read_per_calc = READ_PER_CALC_DEFAULT;
	
	if( (data->tree = tree_alloc(chain, elements_per_level, read_per_calc)) == NULL)
		return error("chain blocks-address no memory"); 
	
	if(tree_recalc(data->tree) != 0){
		tree_free(data->tree);
		return error("chain blocks-address tree recalc failed");
	}
	
	return 0;
}
开发者ID:imaxxs,项目名称:frozen,代码行数:25,代码来源:blocks_addressing.c


示例8: data_length_t_convert_from

static ssize_t data_length_t_convert_from(data_t *dst, fastcall_convert_from *fargs){ // {{{
	ssize_t                ret;
	length_t              *fdata;
	
	if(dst->ptr != NULL)
		return -EINVAL;
	
	switch(fargs->format){
		case FORMAT(hash):;
			hash_t                *config;
			
			data_get(ret, TYPE_HASHT, config, fargs->src);
			if(ret != 0)
				return ret;
			
			if( (fdata = malloc(sizeof(length_t))) == NULL)
				return -ENOMEM;
			
			hash_holder_consume(ret, fdata->data, config, HK(data));
			if(ret != 0){
				free(fdata);
				return -EINVAL;
			}
			
			fdata->format = FORMAT(clean);
			hash_data_get(ret, TYPE_FORMATT, fdata->format, config, HK(format));
			
			dst->ptr = fdata;
			return 0;
			
		default:
			break;
	}
	return -ENOSYS;
} // }}}
开发者ID:allisonmobley,项目名称:frozen,代码行数:35,代码来源:length_t.c


示例9: action_query_to_hash

ssize_t     action_query_to_hash(void *userdata, fastcall_query *fargs, f_fast_to_hash callback){ // {{{
	request_t  r_next[] = {
		{ HK(action),     DATA_PTR_ACTIONT( &fargs->header.action            ) },
		{ HK(request),    DATA_PTR_HASHT( fargs->request                     ) },
		hash_end
	};
	return callback(userdata, r_next);
} // }}}
开发者ID:samuell,项目名称:frozen,代码行数:8,代码来源:api.c


示例10: call_configure

static int call_configure(backend_t *backend, config_t *config){ // {{{
	ssize_t                ret;
	call_userdata         *userdata          = (call_userdata *)backend->userdata;
	
	hash_data_copy(ret, TYPE_HASHKEYT, userdata->hk_backend,    config, HK(input));
	hash_data_copy(ret, TYPE_UINTT,    userdata->retry_request, config, HK(retry));
	return 0;
} // }}}
开发者ID:hyperation,项目名称:frozen,代码行数:8,代码来源:call.c


示例11: action_resize_to_hash

ssize_t     action_resize_to_hash(void *userdata, fastcall_resize *fargs, f_fast_to_hash callback){ // {{{
	request_t  r_next[] = {
		{ HK(action),     DATA_PTR_ACTIONT( &fargs->header.action            ) },
		{ HK(size),       DATA_UINTT(      fargs->length                     ) },
		hash_end
	};
	return callback(userdata, r_next);
} // }}}
开发者ID:samuell,项目名称:frozen,代码行数:8,代码来源:api.c


示例12: action_enum_to_hash

ssize_t     action_enum_to_hash(void *userdata, fastcall_enum *fargs, f_fast_to_hash callback){ // {{{
	request_t  r_next[] = {
		{ HK(action),     DATA_PTR_ACTIONT( &fargs->header.action            ) },
		{ HK(data),      *fargs->dest                                          },
		hash_end
	};
	return callback(userdata, r_next);
} // }}}
开发者ID:samuell,项目名称:frozen,代码行数:8,代码来源:api.c


示例13: data_list_t_convert_to

static ssize_t data_list_t_convert_to(data_t *src, fastcall_convert_to *fargs){ // {{{
	ssize_t                ret               = 0;
	ssize_t                qret;
	list_chunk_t          *chunk;
	list_t                *fdata             = (list_t *)src->ptr;
	data_t                 sl_output         = DATA_SLIDERT(fargs->dest, 0);
	
	switch(fargs->format){
		case FORMAT(packed):;
			for(chunk = fdata->head; chunk; chunk = chunk->cnext){
				// remove ref_t from top
				hash_t           r_key[] = {
					{ 0, DATA_HASHKEYT(HK(data)) },
					hash_end
				};
				data_t           d_key     = DATA_PTR_HASHT(r_key);
				fastcall_control r_control = {
					{ 5, ACTION_CONTROL },
					HK(data),
					&d_key,
					NULL
				};
				if( (ret = data_query(&chunk->data, &r_control)) < 0)
					break;
				
				data_t         d_data             = DATA_PTR_DATAT(r_control.value);
				
				fastcall_convert_to r_convert = { { 5, ACTION_CONVERT_TO }, &sl_output, FORMAT(packed) };
				ret = data_query(&d_data, &r_convert);
				
				data_slider_t_set_offset(&sl_output, r_convert.transfered, SEEK_CUR);
				
				if(ret < 0)
					break;
			}
			
			// terminate list
			data_t                 terminator         = { TYPE_LISTENDT, NULL };
			data_t                 d_data             = DATA_PTR_DATAT(&terminator);
			
			fastcall_convert_to r_convert = { { 5, ACTION_CONVERT_TO }, &sl_output, FORMAT(packed) };
			qret = data_query(&d_data, &r_convert);
			
			data_slider_t_set_offset(&sl_output, r_convert.transfered, SEEK_CUR);
			
			if(qret < 0)
				ret = qret;
			break;
			
		default:
			return -ENOSYS;
	}
	if(fargs->header.nargs >= 5)
		fargs->transfered = data_slider_t_get_offset(&sl_output);
	
	return ret;
} // }}}
开发者ID:samuell,项目名称:frozen,代码行数:57,代码来源:list_t.c


示例14: mphf_init

static int mphf_init(backend_t *backend){ // {{{
	mphf_userdata *userdata = backend->userdata = calloc(1, sizeof(mphf_userdata));
	if(userdata == NULL)
		return error("calloc failed");
	
	userdata->input  = HK(key);
	userdata->output = HK(offset);
	return 0;
} // }}}
开发者ID:hyperation,项目名称:frozen,代码行数:9,代码来源:mphf.c


示例15: try_handler

static ssize_t try_handler(machine_t *machine, request_t *request){ // {{{
	ssize_t               ret;
	data_t                freeme;
	request_t            *try_request;
	try_userdata         *userdata          = (try_userdata *)machine->userdata;
	try_threaddata       *threaddata        = thread_data_get(&userdata->thread_data);
	
	threaddata->machine  = machine;
	threaddata->request  = request;
	threaddata->ret      = 0;
	
	data_set_void(&freeme);
	
	if(userdata->request == 0){
		try_request = request;
	}else{
		if( (ret = get_hash(hash_data_find(request, userdata->request), &freeme, &try_request)) < 0)
			return ret;
	}
	
	request_t r_next[] = {
		{ userdata->return_to, DATA_MACHINET(userdata->try_end) },
		hash_inline(try_request),
		hash_end
	};
	
	fastcall_query r_query = { { 3, ACTION_QUERY }, r_next };
	if( (ret = data_query(&userdata->machine, &r_query)) < 0){
		if(userdata->request == 0){
			request_t r_pass[] = {
				{ HK(ret), DATA_PTR_SIZET(&ret) },
				hash_inline(request),
				hash_end
			};
			threaddata->ret = machine_pass(machine, r_pass);
		}else{
			request_t r_pass[] = {
				{ HK(ret), DATA_PTR_SIZET(&ret) },
				hash_inline(try_request),
				hash_end
			};
			
			request_t r_next[] = {
				{ HK(ret),               DATA_PTR_SIZET(&ret)   },
				{ userdata->request_out, DATA_PTR_HASHT(r_pass) },
				hash_inline(request),
				hash_end
			};
			threaddata->ret = machine_pass(machine, r_next);
		}
	}
	
	data_free(&freeme);
	return threaddata->ret;
} // }}}
开发者ID:allisonmobley,项目名称:frozen,代码行数:55,代码来源:try.c


示例16: murmur_configure

static ssize_t murmur_configure(machine_t *machine, hash_t *config){ // {{{
	ssize_t                ret;
	murmur_userdata       *userdata          = (murmur_userdata *)machine->userdata;
	
	hash_data_get(ret, TYPE_HASHKEYT, userdata->input,    config, HK(input));
	hash_data_get(ret, TYPE_HASHKEYT, userdata->output,   config, HK(output));
	hash_data_get(ret, TYPE_UINTT,    userdata->fatal,    config, HK(fatal));
	
	userdata->fatal   = ( userdata->fatal == 0 ) ? 0 : 1;
	return 0;
} // }}}
开发者ID:samuell,项目名称:frozen,代码行数:11,代码来源:murmur.c


示例17: action_pop_to_hash

ssize_t     action_pop_to_hash(void *userdata, fastcall_pop *fargs, f_fast_to_hash callback){ // {{{
	if(fargs->data == NULL)
		return -EINVAL;
	
	request_t  r_next[] = {
		{ HK(action),     DATA_PTR_ACTIONT( &fargs->header.action            ) },
		{ HK(data),       *fargs->data                                         },
		hash_end
	};
	return callback(userdata, r_next);
} // }}}
开发者ID:samuell,项目名称:frozen,代码行数:11,代码来源:api.c


示例18: tcp_configure

static int tcp_configure(machine_t *machine, hash_t *config){ // {{{
	ssize_t                ret;
	tcp_userdata          *userdata          = (tcp_userdata *)machine->userdata;
	
	hash_data_convert(ret, TYPE_STRINGT, userdata->tcp_addr, config, HK(addr));
	hash_data_get    (ret, TYPE_UINTT,   userdata->tcp_port, config, HK(port));
	hash_data_get    (ret, TYPE_HASHT,   userdata->machine,  config, HK(machine));
	
	tcp_control_start(machine);
	return 0;
} // }}}
开发者ID:allisonmobley,项目名称:frozen,代码行数:11,代码来源:tcp.c


示例19: hashtable_configure

static int hashtable_configure(backend_t *backend, config_t *config){ // {{{
	ssize_t                ret;
	hashtable_userdata    *userdata        = (hashtable_userdata *)backend->userdata;
	
	hash_data_copy(ret, TYPE_HASHKEYT, userdata->input,          config, HK(input));
       	hash_data_copy(ret, TYPE_UINTT,    userdata->hashtable_size, config, HK(nelements));
	
	if(userdata->hashtable_size == 0)
		return error("invalid hashtable size");
	return 0;
} // }}}
开发者ID:imaxxs,项目名称:frozen,代码行数:11,代码来源:hashtable.c


示例20: allocator_new

static ssize_t allocator_new(allocator_fixed_t **pfdata, hash_t *config){ // {{{
	ssize_t                ret;
	data_t                *sample;
	allocator_fixed_t     *fdata;
	
	if((fdata = calloc(1, sizeof(allocator_fixed_t))) == NULL)
		return error("calloc failed");
	
	pthread_rwlock_init(&fdata->rwlock, NULL);
	
	// get removed items tracker
	hash_holder_consume(ret, fdata->removed_items, config, HK(removed_items));
	hash_holder_consume(ret, fdata->storage,       config, HK(storage));
	if(ret != 0){
		ret = error("invalid storage supplied");
		goto error;
	}
	
	hash_data_get(ret, TYPE_UINTT, fdata->item_size, config, HK(item_size));
	if(ret != 0){
		if( (sample = hash_data_find(config, HK(item_sample))) == NULL){
			ret = error("no item_size nor item_sample supplied");
			goto error;
		}
		
		fastcall_length r_len = { { 4, ACTION_LENGTH }, 0, FORMAT(binary) };
		if( data_query(sample, &r_len) != 0 ){
			ret = error("bad item_sample");
			goto error;
		}
		
		fdata->item_size = r_len.length;
	}
	if(fdata->item_size == 0){
		ret = error("bad item size");
		goto error;
	}
	
	// get last id
	fastcall_length r_len = { { 4, ACTION_LENGTH }, 0, FORMAT(clean) };
	if( data_query(&fdata->storage, &r_len) != 0){
		ret = error("bad underlying storage");
		goto error;
	}
	fdata->last_id = r_len.length / fdata->item_size;
	
	*pfdata = fdata;
	return 0;

error:
	allocator_destroy(fdata);
	return ret;
} // }}}
开发者ID:allisonmobley,项目名称:frozen,代码行数:53,代码来源:allocator_fixed_t.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ HKEY函数代码示例发布时间:2022-05-30
下一篇:
C++ HI_UINT16函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap