summaryrefslogtreecommitdiffhomepage
path: root/src/core/ngx_list.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/ngx_list.h')
-rw-r--r--src/core/ngx_list.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/core/ngx_list.h b/src/core/ngx_list.h
new file mode 100644
index 000000000..4da8343fc
--- /dev/null
+++ b/src/core/ngx_list.h
@@ -0,0 +1,48 @@
+#ifndef _NGX_LIST_H_INCLUDED_
+#define _NGX_LIST_H_INCLUDED_
+
+
+#include <ngx_config.h>
+#include <ngx_core.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;
+};
+
+
+typedef struct {
+ ngx_list_part_t *last;
+ ngx_list_part_t part;
+ size_t size;
+ ngx_uint_t nalloc;
+ ngx_pool_t *pool;
+} ngx_list_t;
+
+
+#define ngx_init_list(l, p, n, s, rc) \
+ if (!(l.part.elts = ngx_palloc(p, n * s))) { \
+ return rc; \
+ } \
+ l.part.nelts = 0; l.part.next = NULL; \
+ l.last = &l.part; l.size = s; l.nalloc = n; l.pool = p;
+
+
+#define ngx_iterate_list(p, i) \
+ for ( ;; i++) { \
+ if (i >= p->nelts) { \
+ if (p->next == NULL) { \
+ break; \
+ } \
+ p = p->next; i = 0; \
+ }
+
+
+void *ngx_push_list(ngx_list_t *list);
+
+
+#endif /* _NGX_LIST_H_INCLUDED_ */