nginx-0.0.1-2003-10-23-10:13:16 import
diff --git a/src/core/ngx_alloc.c b/src/core/ngx_alloc.c
index 02c9342..32aa25c 100644
--- a/src/core/ngx_alloc.c
+++ b/src/core/ngx_alloc.c
@@ -20,6 +20,7 @@
     return p;
 }
 
+
 void *ngx_calloc(size_t size, ngx_log_t *log)
 {
     void *p;
@@ -32,6 +33,7 @@
     return p;
 }
 
+
 ngx_pool_t *ngx_create_pool(size_t size, ngx_log_t *log)
 {
     ngx_pool_t *p;
@@ -47,6 +49,7 @@
     return p;
 }
 
+
 void ngx_destroy_pool(ngx_pool_t *pool)
 {
     ngx_pool_t        *p, *n;
@@ -56,7 +59,9 @@
 #if (NGX_DEBUG_ALLOC)
         ngx_log_debug(pool->log, "free: %08x" _ l->alloc);
 #endif
-        free(l->alloc);
+        if (l->alloc) {
+            free(l->alloc);
+        }
     }
 
     /*
@@ -85,6 +90,7 @@
     pool = NULL;
 }
 
+
 void *ngx_palloc(ngx_pool_t *pool, size_t size)
 {
     char              *m;
@@ -107,53 +113,71 @@
             }
         }
 
-        /* alloc new pool block */
+        /* alloc a new pool block */
+
         ngx_test_null(n, ngx_create_pool(p->end - (char *) p, p->log), NULL);
         p->next = n;
         m = n->last;
         n->last += size;
+
         return m;
+    }
 
-    /* alloc large block */
-    } else {
-        large = NULL;
-        last = NULL;
+    /* alloc a large block */
 
-        if (pool->large) {
-            for (last = pool->large; /* void */; last = last->next) {
-                if (last->alloc == NULL) {
-                    large = last;
-                    last = NULL;
-                    break;
-                }
+    large = NULL;
+    last = NULL;
 
-                if (last->next == NULL) {
-                    break;
-                }
+    if (pool->large) {
+        for (last = pool->large; /* void */; last = last->next) {
+            if (last->alloc == NULL) {
+                large = last;
+                last = NULL;
+                break;
+            }
+
+            if (last->next == NULL) {
+                break;
             }
         }
+    }
 
-        if (large == NULL) {
-            ngx_test_null(large, ngx_palloc(pool, sizeof(ngx_pool_large_t)),
-                          NULL);
-            large->next = NULL;
+    if (large == NULL) {
+        ngx_test_null(large, ngx_palloc(pool, sizeof(ngx_pool_large_t)), NULL);
+        large->next = NULL;
+    }
+
+    ngx_test_null(p, ngx_alloc(size, pool->log), NULL);
+
+    if (pool->large == NULL) {
+        pool->large = large;
+
+    } else if (last) {
+        last->next = large;
+    }
+
+    large->alloc = p;
+
+    return p;
+}
+
+
+void ngx_pfree(ngx_pool_t *pool, void *p)
+{
+    ngx_pool_large_t  *l;
+
+    for (l = pool->large; l; l = l->next) {
+        if (p == l->alloc) {
+#if (NGX_DEBUG_ALLOC)
+            ngx_log_debug(pool->log, "free: %08x" _ l->alloc);
+#endif
+            free(l->alloc);
+            l->alloc = NULL;
         }
-
-        ngx_test_null(p, ngx_alloc(size, pool->log), NULL);
-
-        if (pool->large == NULL) {
-            pool->large = large;
-
-        } else if (last) {
-            last->next = large;
-        }
-
-        large->alloc = p;
-
-        return p;
     }
 }
 
+
 void *ngx_pcalloc(ngx_pool_t *pool, size_t size)
 {
     void *p;
diff --git a/src/core/ngx_alloc.h b/src/core/ngx_alloc.h
index b63f4bd..9463611 100644
--- a/src/core/ngx_alloc.h
+++ b/src/core/ngx_alloc.h
@@ -6,9 +6,10 @@
 #include <ngx_core.h>
 
 
-/* NGX_MAX_ALLOC_FROM_POOL should be (PAGE_SIZE - 1), i.e. 4095 on x86.
-   On FreeBSD 5.x it allows to use zero copy send.
-   On Windows NT it decreases number of locked pages in kernel.
+/*
+ * NGX_MAX_ALLOC_FROM_POOL should be (PAGE_SIZE - 1), i.e. 4095 on x86.
+ * On FreeBSD 5.x it allows to use zero copy send.
+ * On Windows NT it decreases number of locked pages in kernel.
  */
 #define NGX_MAX_ALLOC_FROM_POOL 4095
 
@@ -44,6 +45,8 @@
 
 void *ngx_palloc(ngx_pool_t *pool, size_t size);
 void *ngx_pcalloc(ngx_pool_t *pool, size_t size);
+void ngx_pfree(ngx_pool_t *pool, void *p);
+
 
 #define ngx_free   free
 
diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c
index 70da2dc..a5a907a 100644
--- a/src/core/ngx_conf_file.c
+++ b/src/core/ngx_conf_file.c
@@ -546,6 +546,7 @@
     int         flag;
     ngx_str_t  *value;
 
+
     if (*(int *) (p + cmd->offset) != NGX_CONF_UNSET) {
         return "is duplicate";
     }
@@ -596,23 +597,25 @@
 {
     char  *p = conf;
 
-    int         num, len;
+    int        *np;
     ngx_str_t  *value;
 
-    if (*(int *) (p + cmd->offset) != NGX_CONF_UNSET) {
+
+    np = (int *) (p + cmd->offset);
+
+    if (*np != NGX_CONF_UNSET) {
         return "is duplicate";
     }
 
     value = (ngx_str_t *) cf->args->elts;
-
-    len = value[1].len;
-
-    num = ngx_atoi(value[1].data, len);
-    if (num == NGX_ERROR) {
+    *np = ngx_atoi(value[1].data, value[1].len);
+    if (*np == NGX_ERROR) {
         return "invalid number";
     }
 
-    *(int *) (p + cmd->offset) = num;
+    if (cmd->bounds) {
+        return cmd->bounds->check(cf, cmd->bounds, np);
+    }
 
     return NGX_CONF_OK;
 }
@@ -622,11 +625,14 @@
 {
     char  *p = conf;
 
-    int         size, len, scale;
+    int         size, len, scale, *np;
     char        last;
     ngx_str_t  *value;
 
-    if (*(int *) (p + cmd->offset) != NGX_CONF_UNSET) {
+
+    np = (int *) (p + cmd->offset);
+
+    if (*np != NGX_CONF_UNSET) {
         return "is duplicate";
     }
 
@@ -658,8 +664,11 @@
     }
 
     size *= scale;
+    *np = size;
 
-    *(int *) (p + cmd->offset) = size;
+    if (cmd->bounds) {
+        return cmd->bounds->check(cf, cmd->bounds, np);
+    }
 
     return NGX_CONF_OK;
 }
@@ -669,12 +678,15 @@
 {
     char  *p = conf;
 
-    int         size, total, len, scale;
+    int         size, total, len, scale, *np;
     u_int       max, i;
     char        last, *start;
     ngx_str_t  *value;
 
-    if (*(int *) (p + cmd->offset) != NGX_CONF_UNSET) {
+
+    np = (int *) (p + cmd->offset);
+
+    if (*np != NGX_CONF_UNSET) {
         return "is duplicate";
     }
 
@@ -756,7 +768,11 @@
         start = &value[1].data[i + 1];
     }
 
-    *(int *) (p + cmd->offset) = total;
+    *np = total;
+
+    if (cmd->bounds) {
+        return cmd->bounds->check(cf, cmd->bounds, np);
+    }
 
     return NGX_CONF_OK;
 }
@@ -766,12 +782,15 @@
 {
     char  *p = conf;
 
-    int         size, total, len, scale;
+    int         size, total, len, scale, *np;
     u_int       max, i;
     char        last, *start;
     ngx_str_t  *value;
 
-    if (*(int *) (p + cmd->offset) != NGX_CONF_UNSET) {
+
+    np = (int *) (p + cmd->offset);
+
+    if (*np != NGX_CONF_UNSET) {
         return "is duplicate";
     }
 
@@ -865,7 +884,11 @@
         start = &value[1].data[i + 1];
     }
 
-    *(int *) (p + cmd->offset) = total;
+    *np = total;
+
+    if (cmd->bounds) {
+        return cmd->bounds->check(cf, cmd->bounds, np);
+    }
 
     return NGX_CONF_OK;
 }
@@ -929,3 +952,17 @@
 {
     return "unsupported on this platform";
 }
+
+
+char *ngx_conf_check_num_bounds(ngx_conf_t *cf, ngx_conf_bounds_t *bounds,
+                                void *conf)
+{
+    int *num = conf;
+
+    if (*num >= bounds->type.num.low && *num <= bounds->type.num.high) {
+        return NGX_CONF_OK;
+
+    }
+
+    return "invalid value";
+}
diff --git a/src/core/ngx_conf_file.h b/src/core/ngx_conf_file.h
index 66ca2a9..e09cc65 100644
--- a/src/core/ngx_conf_file.h
+++ b/src/core/ngx_conf_file.h
@@ -52,17 +52,37 @@
 #define NGX_CONF_MODULE      0x464E4F43  /* "CONF" */
 
 
+typedef struct ngx_conf_bounds_s ngx_conf_bounds_t;
 
-struct ngx_command_s {
-    ngx_str_t  name;
-    int        type;
-    char    *(*set)(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
-    int        conf;
-    int        offset;
-    void      *bounds;
+struct ngx_conf_bounds_s {
+    char     *(*check)(ngx_conf_t *cf, ngx_conf_bounds_t *bounds, void *conf);
+
+    union {
+        struct {
+           int  low;
+           int  high;
+        } num;
+
+        struct num {
+           int  low_num;
+           int  high_num;
+           int  low_size;
+           int  high_size;
+        } bufs;
+   } type;
 };
 
-#define ngx_null_command   {ngx_null_string, 0, NULL, 0, 0, NULL}
+
+struct ngx_command_s {
+    ngx_str_t           name;
+    int                 type;
+    char             *(*set)(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
+    int                 conf;
+    int                 offset;
+    ngx_conf_bounds_t  *bounds;
+};
+
+#define ngx_null_command   { ngx_null_string, 0, NULL, 0, 0, NULL }
 
 
 struct ngx_open_file_s {
@@ -221,6 +241,9 @@
 char *ngx_conf_set_core_flag_slot(ngx_conf_t *cf, ngx_command_t *cmd,
                                   void *conf);
 
+char *ngx_conf_check_num_bounds(ngx_conf_t *cf, ngx_conf_bounds_t *bounds,
+                                void *conf);
+
 
 extern ngx_module_t     *ngx_modules[];
 extern ngx_cycle_t      *ngx_cycle;
diff --git a/src/core/ngx_file.c b/src/core/ngx_file.c
index 538adff..2383e5c 100644
--- a/src/core/ngx_file.c
+++ b/src/core/ngx_file.c
@@ -203,5 +203,5 @@
         path->level[i++] = 0;
     }
 
-    return NULL;
+    return NGX_CONF_OK;
 }