Back to home page

Nginx displayed by LXR

Source navigation ]
Diff markup ]
Identifier search ]
general search ]
 
 
Version: nginx-1.15.11 ]​[ nginx-1.14.2 ]​

0001 
0002 /*
0003  * Copyright (C) Igor Sysoev
0004  * Copyright (C) Nginx, Inc.
0005  */
0006 
0007 
0008 #ifndef _NGX_LIST_H_INCLUDED_
0009 #define _NGX_LIST_H_INCLUDED_
0010 
0011 
0012 #include <ngx_config.h>
0013 #include <ngx_core.h>
0014 
0015 
0016 typedef struct ngx_list_part_s  ngx_list_part_t;
0017 
0018 struct ngx_list_part_s {
0019     void             *elts;
0020     ngx_uint_t        nelts;
0021     ngx_list_part_t  *next;
0022 };
0023 
0024 
0025 typedef struct {
0026     ngx_list_part_t  *last;
0027     ngx_list_part_t   part;
0028     size_t            size;
0029     ngx_uint_t        nalloc;
0030     ngx_pool_t       *pool;
0031 } ngx_list_t;
0032 
0033 
0034 ngx_list_t *ngx_list_create(ngx_pool_t *pool, ngx_uint_t n, size_t size);
0035 
0036 static ngx_inline ngx_int_t
0037 ngx_list_init(ngx_list_t *list, ngx_pool_t *pool, ngx_uint_t n, size_t size)
0038 {
0039     list->part.elts = ngx_palloc(pool, n * size);
0040     if (list->part.elts == NULL) {
0041         return NGX_ERROR;
0042     }
0043 
0044     list->part.nelts = 0;
0045     list->part.next = NULL;
0046     list->last = &list->part;
0047     list->size = size;
0048     list->nalloc = n;
0049     list->pool = pool;
0050 
0051     return NGX_OK;
0052 }
0053 
0054 
0055 /*
0056  *
0057  *  the iteration through the list:
0058  *
0059  *  part = &list.part;
0060  *  data = part->elts;
0061  *
0062  *  for (i = 0 ;; i++) {
0063  *
0064  *      if (i >= part->nelts) {
0065  *          if (part->next == NULL) {
0066  *              break;
0067  *          }
0068  *
0069  *          part = part->next;
0070  *          data = part->elts;
0071  *          i = 0;
0072  *      }
0073  *
0074  *      ...  data[i] ...
0075  *
0076  *  }
0077  */
0078 
0079 
0080 void *ngx_list_push(ngx_list_t *list);
0081 
0082 
0083 #endif /* _NGX_LIST_H_INCLUDED_ */