diff src/core/ngx_hunk.c @ 16:6ce4755737b4

nginx-0.0.1-2002-09-26-20:50:29 import
author Igor Sysoev <igor@sysoev.ru>
date Thu, 26 Sep 2002 16:50:29 +0000
parents 708f8bb772ec
children cd035a94e0b6
line wrap: on
line diff
--- a/src/core/ngx_hunk.c
+++ b/src/core/ngx_hunk.c
@@ -5,13 +5,15 @@
 ngx_hunk_t *ngx_create_temp_hunk(ngx_pool_t *pool, int size,
                                  int before, int after)
 {
-    ngx_hunk_t *h = ngx_palloc(pool, sizeof(ngx_hunk_t));
+    ngx_hunk_t *h;
+
+    ngx_test_null(h, ngx_palloc(pool, sizeof(ngx_hunk_t)), NULL);
 
 #if !(HAVE_OFFSET_EQUAL_PTR)
     h->pos.file = h->last.file = 0;
 #endif
 
-    h->pre_start = ngx_palloc(pool, size + before + after);
+    ngx_test_null(h->pre_start, ngx_palloc(pool, size + before + after), NULL);
     h->start = h->pos.mem = h->last.mem = h->pre_start + before;
     h->end = h->last.mem + size;
     h->post_end = h->end + after;
@@ -25,7 +27,9 @@ ngx_hunk_t *ngx_create_temp_hunk(ngx_poo
     
 ngx_hunk_t *ngx_create_hunk_before(ngx_pool_t *pool, ngx_hunk_t *hunk, int size)
 {    
-    ngx_hunk_t *h = ngx_palloc(pool, sizeof(ngx_hunk_t));
+    ngx_hunk_t *h;
+
+    ngx_test_null(h, ngx_palloc(pool, sizeof(ngx_hunk_t)), NULL);
 
 #if !(HAVE_OFFSET_EQUAL_PTR)
     h->pos.file = h->last.file = 0;
@@ -42,8 +46,8 @@ ngx_hunk_t *ngx_create_hunk_before(ngx_p
         h->file = NULL;
 
     } else {
-        h->pre_start = h->start = h->pos.mem = h->last.mem
-                                                      = ngx_palloc(pool, size);
+        ngx_test_null(h->pre_start, ngx_palloc(pool, size), NULL);
+        h->start = h->pos.mem = h->last.mem = h->pre_start; 
         h->end = h->post_end = h->start + size;
 
         h->type = NGX_HUNK_TEMP;
@@ -56,7 +60,9 @@ ngx_hunk_t *ngx_create_hunk_before(ngx_p
 
 ngx_hunk_t *ngx_create_hunk_after(ngx_pool_t *pool, ngx_hunk_t *hunk, int size)
 {
-    ngx_hunk_t *h = ngx_palloc(pool, sizeof(ngx_hunk_t));
+    ngx_hunk_t *h;
+
+    ngx_test_null(h, ngx_palloc(pool, sizeof(ngx_hunk_t)), NULL);
 
 #if !(HAVE_OFFSET_EQUAL_PTR)
     h->pos.file = h->last.file = 0;
@@ -74,8 +80,8 @@ ngx_hunk_t *ngx_create_hunk_after(ngx_po
         h->file = NULL;
 
     } else {
-        h->pre_start = h->start = h->pos.mem = h->last.mem =
-                                                        ngx_palloc(pool, size);
+        ngx_test_null(h->pre_start, ngx_palloc(pool, size), NULL);
+        h->start = h->pos.mem = h->last.mem = h->pre_start; 
         h->end = h->post_end = h->start + size;
 
         h->type = NGX_HUNK_TEMP;