设为首页 加入收藏

TOP

移植最新版libmemcached到VC++的艰苦历程和经验总结(下) (二)
2014-11-23 21:25:15 】 浏览:1372
Tags:移植 最新版 libmemcached 艰苦 历程 经验 总结
ue);
38 int MCWRAPPER_CALL wrapped_memcached_decrement_with_initial(void* p
39 ,const char* key,size_t klength,uint64 step,uint64 initial,uint64* value);
40 }

  通过封装函数的签名可以看出,所有和libmemcached相关的结构体指针在此均被定义为void*类型,这样就可以规避上一篇中提到的结构体由不同编译器生成的字节对齐问题。最后,在封装函数的内部只需要将void*转换回其封装的libmemcached导出函数参数期望的结构体指针类型即可,实现代码如下:

1#include
2 #include
3
4 void* MCWRAPPER_CALL wrapped_memcached_create()
5 {
6 return (void*)memcached_create(NULL);
7 }
8
9 void MCWRAPPER_CALL wrapped_memcached_free(void* p)
10 {
11 memcached_free((memcached_st*)p);
12 }
13
14 const char* MCWRAPPER_CALL wrapped_memcached_strerror(void* p, int error)
15 {
16 return memcached_strerror((memcached_st*)p,(memcached_return)error);
17 }
18
19 int MCWRAPPER_CALL wrapped_memcached_behavior_set(void *p, const int flag, uint64 data)
20 {
21 return memcached_behavior_set((memcached_st*)p,(memcached_behavior_t)flag,data);
22 }
23
24 int MCWRAPPER_CALL wrapped_memcached_behavior_set_distribution(void* p, int type)
25 {
26 return memcached_behavior_set_distribution((memcached_st*)p
27 ,(memcached_server_distribution_t)type);
28 }
29
30 int MCWRAPPER_CALL wrapped_memcached_server_add(void* p,const char* hostname, uint16 port)
31 {
32 return memcached_server_add((memcached_st*)p,hostname,port);
33 }
34
35 uint32 MCWRAPPER_CALL wrapped_memcached_server_count(const void* p)
36 {
37 return memcached_server_count((memcached_st*)p);
38 }
39
40 int MCWRAPPER_CALL wrapped_memcached_set(void* p,const char* key,size_t klength
41 ,const char* data,size_t dlength)
42 {
43 return memcached_set((memcached_st*)p,key,klength,data,dlength,0,0);
44 }
45
46 int MCWRAPPER_CALL wrapped_memcached_add(void* p,const char *key,size_t klength
47 ,const char* data,size_t dlength)
48 {
49 return memcached_add((memcached_st*)p,key,klength,data,dlength,0,0);
50 }
51
52 int MCWRAPPER_CALL wrapped_memcached_replace(void* p,const char* key,size_t klength
53 ,const char* data,size_t dlength)
54 {
55 return memcached_replace((memcached_st*)p,key,klength,data,dlength,0,0);
56 }
57
58 int MCWRAPPER_CALL wrapped_memcached_append(void* p,const char* key,size_t klength
59 ,const char* data,size_t dlength)
60 {
61 return memcached_append((memcached_st*)p,key,klength,data,dlength,0,0);
62 }
63
64 char* MCWRAPPER_CALL wrapped_memcached_get(void* p,const char* key,size_t klength
65 ,size_t* dlength,uint32* flags,int* error)
66 {
67 return memcached_get((memcached_st*)p,key,klength,dlength,flags,(memcached_return_t*)error);
68 }
69
70 int MCWRAPPER_CALL wrapped_memcached_mget(void* p,const char* const* keys
71 ,const size_t* keysLength,size_t numberOfkeys)
72 {
73 return memcached_mget((memcached_st*)p,keys,keysLength, numberOfkeys);
74
75 }
76
77 void* MCWRAPPER_CALL wrapped_memcached_fetch_result(void* p,void* result,int* error)
78 {
79 return (void*)memcached_fetch_result((memcached_st*)p,NULL,(memcached_return_t*)error);
80 }
81
82 const char* MCWRAPPER_CALL wrapped_memcached_result_value(const void* self)
83 {
84 return memcached_result_value((const memcached_result_st*)self);
85 }
86
87 size_t MCWRAPPER_CALL w

首页 上一页 1 2 3 4 下一页 尾页 2/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇vc.net中实现启动画面来个淡入淡出 下一篇VC#中从Clipboard保存获取数据的..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目