zoukankan      html  css  js  c++  java
  • nginx中ngx_list的数据结构

    今天没事了,在查看nginx源代码中看到ngx_list的结构,发现设计为链表数组的形式,不知道为什么这样设计

    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; //链表中数组元素一旦分配之后是不可更改的,nalloc表示每个ngx_list_part_t数组的容量,即最多可存储多少个数据
        ngx_pool_t       *pool;//链表中管理内存分配的内存池对象
    } ngx_list_t;
    

     只实现三个方法:

    ngx_list_t *ngx_list_create(ngx_pool_t *pool, ngx_uint_t n, size_t size);

    static ngx_inline ngx_int_t ngx_list_init(ngx_list_t *list, ngx_pool_t *pool, ngx_uint_t n, size_t size);私有方法 在ngx_list_create中调用

    void *ngx_list_push(ngx_list_t *list);

  • 相关阅读:
    Linux安装nginx
    Linux安装vsftp服务
    maven的Tomcat插件使用
    Mybatis逆向工程生成代码
    千里之行,始于足下
    java 通过反射获取注解
    天气预报需要用到的jar包
    JDBC 利用反射 配置文件
    从网页下载图片的代码
    装箱/拆箱 对象排序
  • 原文地址:https://www.cnblogs.com/hylaz/p/4471285.html
Copyright © 2011-2022 走看看