Mercurial > hg > nginx-vendor-1-0
comparison src/core/ngx_list.h @ 0:f0b350454894 NGINX_0_1_0
nginx 0.1.0
*) The first public version.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 04 Oct 2004 00:00:00 +0400 |
parents | |
children | 74b1868dd3cd |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0b350454894 |
---|---|
1 | |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4 */ | |
5 | |
6 | |
7 #ifndef _NGX_LIST_H_INCLUDED_ | |
8 #define _NGX_LIST_H_INCLUDED_ | |
9 | |
10 | |
11 #include <ngx_config.h> | |
12 #include <ngx_core.h> | |
13 | |
14 | |
15 typedef struct ngx_list_part_s ngx_list_part_t; | |
16 | |
17 struct ngx_list_part_s { | |
18 void *elts; | |
19 ngx_uint_t nelts; | |
20 ngx_list_part_t *next; | |
21 }; | |
22 | |
23 | |
24 typedef struct { | |
25 ngx_list_part_t *last; | |
26 ngx_list_part_t part; | |
27 size_t size; | |
28 ngx_uint_t nalloc; | |
29 ngx_pool_t *pool; | |
30 } ngx_list_t; | |
31 | |
32 | |
33 ngx_inline static ngx_int_t ngx_list_init(ngx_list_t *list, ngx_pool_t *pool, | |
34 ngx_uint_t n, size_t size) | |
35 { | |
36 if (!(list->part.elts = ngx_palloc(pool, n * size))) { | |
37 return NGX_ERROR; | |
38 } | |
39 | |
40 list->part.nelts = 0; | |
41 list->part.next = NULL; | |
42 list->last = &list->part; | |
43 list->size = size; | |
44 list->nalloc = n; | |
45 list->pool = pool; | |
46 | |
47 return NGX_OK; | |
48 } | |
49 | |
50 | |
51 /* | |
52 * | |
53 * the iteration through the list: | |
54 * | |
55 * part = &list.part; | |
56 * data = part->elts; | |
57 * | |
58 * for (i = 0 ;; i++) { | |
59 * | |
60 * if (i >= part->nelts) { | |
61 * if (part->next == NULL) { | |
62 * break; | |
63 * } | |
64 * | |
65 * part = part->next; | |
66 * data = part->elts; | |
67 * i = 0; | |
68 * } | |
69 * | |
70 * ... data[i] ... | |
71 * | |
72 * } | |
73 */ | |
74 | |
75 | |
76 void *ngx_list_push(ngx_list_t *list); | |
77 | |
78 | |
79 #endif /* _NGX_LIST_H_INCLUDED_ */ |