nginx源码解析之常用数据结构
1、基础数据结构(src/core目录) 1)ngx_list_t(ngx_list.h) 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; // 下一个链表元素ngx_list_part_t的地址 }; typedef struct { ngx_list_part_t *last; // 指向链表的最后一个数组元素 ngx_list_part_t part; // 链表的首个数组元素 size_t size; // 存储的每个数据的字节数必须小于或等于size ngx_uint_t nalloc; // 每个ngx_list_part_t数组的容量 ngx_pool_t *pool; // 链表中管理内存分配的内存池对象 } ngx_list_t; // 描述整个链表 相关接口: ngx_list_create(): 创建新的链表。 ngx_list_init(): 初始化一个已有的链表。返回 NGX_OK 表示成功,返回 NGX_ERROR 表示失败。 ngx_list