diff src/core/ngx_hunk.c @ 166:389d7ee9fa60

nginx-0.0.1-2003-10-30-11:51:06 import
author Igor Sysoev <igor@sysoev.ru>
date Thu, 30 Oct 2003 08:51:06 +0000
parents e7e094d34162
children 8aef3c72e5da
line wrap: on
line diff
--- a/src/core/ngx_hunk.c
+++ b/src/core/ngx_hunk.c
@@ -3,19 +3,21 @@
 #include <ngx_core.h>
 
 
-ngx_hunk_t *ngx_create_temp_hunk(ngx_pool_t *pool, int size,
-                                 int before, int after)
+ngx_hunk_t *ngx_create_temp_hunk(ngx_pool_t *pool, int size)
 {
     ngx_hunk_t *h;
 
-    ngx_test_null(h, ngx_palloc(pool, sizeof(ngx_hunk_t)), NULL);
+    ngx_test_null(h, ngx_alloc_hunk(pool), NULL);
 
-    ngx_test_null(h->pre_start, ngx_palloc(pool, size + before + after), NULL);
+    ngx_test_null(h->start, ngx_palloc(pool, size), NULL);
 
-    h->start = h->pos = h->last = h->pre_start + before;
-    h->file_pos = h->file_last = 0;
+    h->pos = h->start;
+    h->last = h->start;
+
+    h->file_pos = 0;
+    h->file_last = 0;
+
     h->end = h->last + size;
-    h->post_end = h->end + after;
 
     h->type = NGX_HUNK_TEMP|NGX_HUNK_IN_MEMORY;
     h->file = NULL;
@@ -68,80 +70,6 @@ ngx_chain_t *ngx_create_chain_of_hunks(n
 }
 
 
-ngx_hunk_t *ngx_create_hunk_before(ngx_pool_t *pool, ngx_hunk_t *hunk, int size)
-{
-    ngx_hunk_t *h;
-
-    ngx_test_null(h, ngx_palloc(pool, sizeof(ngx_hunk_t)), NULL);
-
-    if (hunk->type & NGX_HUNK_TEMP && hunk->pos - hunk->pre_start >= size) {
-        /* keep hunk->start unchanged - used in restore */
-        h->pre_start = hunk->pre_start;
-        h->end = h->post_end = hunk->pre_start = hunk->pos;
-        h->start = h->pos = h->last = h->end - size;
-        h->file_pos = h->file_last = 0;
-
-        h->type = NGX_HUNK_TEMP|NGX_HUNK_IN_MEMORY;
-        h->file = NULL;
-        h->shadow = NULL;
-
-        h->tag = 0;
-
-    } else {
-        ngx_test_null(h->pre_start, ngx_palloc(pool, size), NULL);
-        h->start = h->pos = h->last = h->pre_start;
-        h->end = h->post_end = h->start + size;
-        h->file_pos = h->file_last = 0;
-
-        h->type = NGX_HUNK_TEMP|NGX_HUNK_IN_MEMORY;
-        h->file = NULL;
-        h->shadow = NULL;
-
-        h->tag = 0;
-    }
-
-    return h;
-}
-
-
-ngx_hunk_t *ngx_create_hunk_after(ngx_pool_t *pool, ngx_hunk_t *hunk, int size)
-{
-    ngx_hunk_t *h;
-
-    ngx_test_null(h, ngx_palloc(pool, sizeof(ngx_hunk_t)), NULL);
-
-    if (hunk->type & NGX_HUNK_TEMP
-        && hunk->last == hunk->end
-        && hunk->post_end - hunk->end >= size)
-    {
-        h->post_end = hunk->post_end;
-        h->pre_start = h->start = h->pos = h->last = hunk->post_end =
-                                                                hunk->last;
-        h->file_pos = h->file_last = 0;
-
-        h->type = NGX_HUNK_TEMP|NGX_HUNK_IN_MEMORY;
-        h->file = NULL;
-        h->shadow = NULL;
-
-        h->tag = 0;
-
-    } else {
-        ngx_test_null(h->pre_start, ngx_palloc(pool, size), NULL);
-        h->start = h->pos = h->last = h->pre_start;
-        h->end = h->post_end = h->start + size;
-        h->file_pos = h->file_last = 0;
-
-        h->type = NGX_HUNK_TEMP|NGX_HUNK_IN_MEMORY;
-        h->file = NULL;
-        h->shadow = NULL;
-
-        h->tag = 0;
-    }
-
-    return h;
-}
-
-
 int ngx_chain_add_copy(ngx_pool_t *pool, ngx_chain_t **chain, ngx_chain_t *in)
 {
     ngx_chain_t  *cl, **ll;