下面主要介绍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里的链表。
本文介绍了Nginx中使用的几种关键数据结构,包括ngx_int_t和ngx_uint_t整型定义、ngx_str_t字符串类型及其特点,以及ngx_list_t链表结构。这些数据结构为Nginx提供了高效的基础支撑。
843

被折叠的 条评论
为什么被折叠?



