下面主要介绍nginx里用的数据结构,以后读源码当然还会回过头来看看。
在nginx里的变量类型一般都以ngx开头
typedef intptr_t ngx_int_t
typedef uintptr_t ngx_uint_t
分别定义了ngx里的有符号和无符号整数。
其中intptr_t的定义如下:typedef long int intptr_t
typedef struct {
size_t len;
u_char * data;
} ngx_str_t;
定义了ngx里的string类型,nginx里的string 没有\0,不过引入了len这个参数。
typedef struct ngx_list_part_s ngx_list_part_t;
struct ngx_list_part_s{
void *elts;
ngx_uint_t nelts;
ngx_list_part_t *next;
};
typedef struct{
ngx_list_part_t *last;
ngx_list_part_t part;
size_t size;
ngx_uint_t nalloc;
ngx_pool_t *pool;
} ngx_list_t;
ngx_list_t是nginx里的链表。