Mercurial > hg > nginx
comparison src/core/ngx_list.h @ 415:3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sun, 05 Sep 2004 19:54:02 +0000 |
parents | 388a842cbbe1 |
children | b9bd635011de |
comparison
equal
deleted
inserted
replaced
414:388a842cbbe1 | 415:3c56e834be46 |
---|---|
22 ngx_uint_t nalloc; | 22 ngx_uint_t nalloc; |
23 ngx_pool_t *pool; | 23 ngx_pool_t *pool; |
24 } ngx_list_t; | 24 } ngx_list_t; |
25 | 25 |
26 | 26 |
27 #define ngx_init_list(l, p, n, s, rc) \ | 27 ngx_inline static ngx_int_t ngx_init_list(ngx_list_t *list, ngx_pool_t *pool, |
28 if (!(l.part.elts = ngx_palloc(p, n * s))) { \ | 28 ngx_uint_t n, size_t size) |
29 return rc; \ | 29 { |
30 } \ | 30 if (!(list->part.elts = ngx_palloc(pool, n * size))) { |
31 l.part.nelts = 0; l.part.next = NULL; \ | 31 return NGX_ERROR; |
32 l.last = &l.part; l.size = s; l.nalloc = n; l.pool = p; | 32 } |
33 | |
34 list->part.nelts = 0; | |
35 list->part.next = NULL; | |
36 list->last = &list->part; | |
37 list->size = size; | |
38 list->nalloc = n; | |
39 list->pool = pool; | |
40 | |
41 return NGX_OK; | |
42 } | |
33 | 43 |
34 | 44 |
35 #define ngx_iterate_list(p, i) \ | 45 /* |
36 for ( ;; i++) { \ | 46 * |
37 if (i >= p->nelts) { \ | 47 * the iteration through the list: |
38 if (p->next == NULL) { \ | 48 * |
39 break; \ | 49 * part = &list.part; |
40 } \ | 50 * data = part->elts; |
41 p = p->next; i = 0; \ | 51 * |
42 } | 52 * for (i = 0 ;; i++) { |
53 * | |
54 * if (i >= part->nelts) { | |
55 * if (part->next == NULL) { | |
56 * break; | |
57 * } | |
58 * | |
59 * part = part->next; | |
60 * data = part->elts; | |
61 * i = 0; | |
62 * } | |
63 * | |
64 * ... data[i] ... | |
65 * | |
66 * } | |
67 */ | |
43 | 68 |
44 | 69 |
45 void *ngx_push_list(ngx_list_t *list); | 70 void *ngx_push_list(ngx_list_t *list); |
46 | 71 |
47 | 72 |