diff 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
line wrap: on
line diff
--- a/src/core/ngx_list.h
+++ b/src/core/ngx_list.h
@@ -24,22 +24,47 @@ typedef struct {
 } 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;
+ngx_inline static ngx_int_t ngx_init_list(ngx_list_t *list, ngx_pool_t *pool,
+                                          ngx_uint_t n, size_t size)
+{
+    if (!(list->part.elts = ngx_palloc(pool, n * size))) {
+        return NGX_ERROR;
+    }
+
+    list->part.nelts = 0;
+    list->part.next = NULL;
+    list->last = &list->part;
+    list->size = size;
+    list->nalloc = n;
+    list->pool = pool;
+
+    return NGX_OK;
+}
 
 
-#define ngx_iterate_list(p, i)                                               \
-            for ( ;; i++) {                                                  \
-                if (i >= p->nelts) {                                         \
-                    if (p->next == NULL) {                                   \
-                        break;                                               \
-                    }                                                        \
-                    p = p->next; i = 0;                                      \
-                }
+/*
+ *
+ *  the iteration through the list:
+ *
+ *  part = &list.part;
+ *  data = part->elts;
+ *
+ *  for (i = 0 ;; i++) {
+ *
+ *      if (i >= part->nelts) {
+ *          if (part->next == NULL) {
+ *              break;
+ *          }
+ *
+ *          part = part->next;
+ *          data = part->elts;
+ *          i = 0;
+ *      }
+ *
+ *      ...  data[i] ...
+ *
+ *  }
+ */
 
 
 void *ngx_push_list(ngx_list_t *list);