2014年7月1日

摘自GNU C中的typeof

摘要: 6.6 Referring to a Type withtypeofAnother way to refer to the type of an expression is withtypeof. The syntax of using of this keyword looks likesizeo... 阅读全文

posted @ 2014-07-01 10:37 eric.geoffrey 阅读(279) 评论(0) 推荐(0) 编辑

摘自GNU C中的语句表达式

摘要: 6.1 Statements and Declarations in ExpressionsA compound statement enclosed in parentheses may appear as an expression in GNU C. This allows you to us... 阅读全文

posted @ 2014-07-01 10:12 eric.geoffrey 阅读(364) 评论(0) 推荐(0) 编辑

括号的英文表达

摘要: 1. () (round brackets or parentheses):圆括号2. [] (square brackets):方括号3. (angle brackets):尖括号4. {} (braces) :大括号 阅读全文

posted @ 2014-07-01 10:07 eric.geoffrey 阅读(1722) 评论(0) 推荐(0) 编辑

2014年6月27日

计算结构体首地址的技巧

摘要: struct ABC{ int a; int b; int c;};+----------+ member_name )【分析】:(1) 该宏中,struct_type为结构体类型,member_name为结构体内的变量名 (2) ((struct_type *)0) 是欺骗编... 阅读全文

posted @ 2014-06-27 11:36 eric.geoffrey 阅读(2175) 评论(0) 推荐(0) 编辑

2014年6月21日

别再重复造轮子了,利用list创建任意数据类型的链表

摘要: 链表用处很广,多数情况下都需要自己开发,每次都要重复相同/类似的动作,Linux内核中的list是一个非常好用的链表,而且可移植性比价高,这里介绍一下如何使用:#include #include #include //VC6 模拟定义下面两行,因为这个环境不支持下面两个关键字#ifdef WIN32... 阅读全文

posted @ 2014-06-21 17:44 eric.geoffrey 阅读(314) 评论(0) 推荐(0) 编辑

2014年6月18日

可配置内存池实现

摘要: 源码:可配置内存池【有密码】使用了list原理,实现了可配置的内存,由应用配置,一块内存配置成什么样的内存池。比如用户申请了1M内存,划分成多块进行管理,然后使用。+----------------------+----------------------------------+---------... 阅读全文

posted @ 2014-06-18 17:20 eric.geoffrey 阅读(142) 评论(0) 推荐(0) 编辑

2014年6月14日

简单内存池实现

摘要: 源码下载,实现实现思想:1. 首先预先分配4M Byte的空间用来作为内存池进行操作2. 将这个预先分配的4M内存进行块划分,比如分配出132个64字节的内存块,10个160K字节的内存块3. 获取内存时,在池子中寻找最接近请求的大小的内存块中取出一块,然后标记为占用,比如请求16个字节的空间,那么... 阅读全文

posted @ 2014-06-14 11:26 eric.geoffrey 阅读(160) 评论(0) 推荐(0) 编辑

2014年6月8日

基于本博客版本中的循环缓冲的测试(Linux环境)

摘要: #include #include #include #include "ringbuffer.h"static int b_flag = 0;pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;#define TX_LOCK(lock) pthr... 阅读全文

posted @ 2014-06-08 10:39 eric.geoffrey 阅读(281) 评论(0) 推荐(0) 编辑

2014年6月6日

循环缓冲实现(ring buffer/circular buffer)

摘要: /***************************************************************************************************** buf : 存放数据的缓冲区地址* size: 缓冲区的大小(必须是2的幂)* in :写指针... 阅读全文

posted @ 2014-06-06 15:43 eric.geoffrey 阅读(3165) 评论(0) 推荐(1) 编辑

recvfrom超时设置

摘要: recvfrom阻塞接收的问题,网络不通就一直等,想改成非阻塞的,也不可靠谱。最后设置了一个超时时间 struct timeval tv_out; tv_out.tv_sec = 5;//等待10秒 tv_out.tv_usec = 0;setsockopt(s... 阅读全文

posted @ 2014-06-06 15:37 eric.geoffrey 阅读(1315) 评论(0) 推荐(0) 编辑

导航