comparison 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
comparison
equal deleted inserted replaced
15:cbb38b60495c 16:6ce4755737b4
3 3
4 4
5 ngx_hunk_t *ngx_create_temp_hunk(ngx_pool_t *pool, int size, 5 ngx_hunk_t *ngx_create_temp_hunk(ngx_pool_t *pool, int size,
6 int before, int after) 6 int before, int after)
7 { 7 {
8 ngx_hunk_t *h = ngx_palloc(pool, sizeof(ngx_hunk_t)); 8 ngx_hunk_t *h;
9
10 ngx_test_null(h, ngx_palloc(pool, sizeof(ngx_hunk_t)), NULL);
9 11
10 #if !(HAVE_OFFSET_EQUAL_PTR) 12 #if !(HAVE_OFFSET_EQUAL_PTR)
11 h->pos.file = h->last.file = 0; 13 h->pos.file = h->last.file = 0;
12 #endif 14 #endif
13 15
14 h->pre_start = ngx_palloc(pool, size + before + after); 16 ngx_test_null(h->pre_start, ngx_palloc(pool, size + before + after), NULL);
15 h->start = h->pos.mem = h->last.mem = h->pre_start + before; 17 h->start = h->pos.mem = h->last.mem = h->pre_start + before;
16 h->end = h->last.mem + size; 18 h->end = h->last.mem + size;
17 h->post_end = h->end + after; 19 h->post_end = h->end + after;
18 20
19 h->type = NGX_HUNK_TEMP; 21 h->type = NGX_HUNK_TEMP;
23 return h; 25 return h;
24 } 26 }
25 27
26 ngx_hunk_t *ngx_create_hunk_before(ngx_pool_t *pool, ngx_hunk_t *hunk, int size) 28 ngx_hunk_t *ngx_create_hunk_before(ngx_pool_t *pool, ngx_hunk_t *hunk, int size)
27 { 29 {
28 ngx_hunk_t *h = ngx_palloc(pool, sizeof(ngx_hunk_t)); 30 ngx_hunk_t *h;
31
32 ngx_test_null(h, ngx_palloc(pool, sizeof(ngx_hunk_t)), NULL);
29 33
30 #if !(HAVE_OFFSET_EQUAL_PTR) 34 #if !(HAVE_OFFSET_EQUAL_PTR)
31 h->pos.file = h->last.file = 0; 35 h->pos.file = h->last.file = 0;
32 #endif 36 #endif
33 37
40 h->type = NGX_HUNK_TEMP; 44 h->type = NGX_HUNK_TEMP;
41 h->tag = 0; 45 h->tag = 0;
42 h->file = NULL; 46 h->file = NULL;
43 47
44 } else { 48 } else {
45 h->pre_start = h->start = h->pos.mem = h->last.mem 49 ngx_test_null(h->pre_start, ngx_palloc(pool, size), NULL);
46 = ngx_palloc(pool, size); 50 h->start = h->pos.mem = h->last.mem = h->pre_start;
47 h->end = h->post_end = h->start + size; 51 h->end = h->post_end = h->start + size;
48 52
49 h->type = NGX_HUNK_TEMP; 53 h->type = NGX_HUNK_TEMP;
50 h->tag = 0; 54 h->tag = 0;
51 h->file = NULL; 55 h->file = NULL;
54 return h; 58 return h;
55 } 59 }
56 60
57 ngx_hunk_t *ngx_create_hunk_after(ngx_pool_t *pool, ngx_hunk_t *hunk, int size) 61 ngx_hunk_t *ngx_create_hunk_after(ngx_pool_t *pool, ngx_hunk_t *hunk, int size)
58 { 62 {
59 ngx_hunk_t *h = ngx_palloc(pool, sizeof(ngx_hunk_t)); 63 ngx_hunk_t *h;
64
65 ngx_test_null(h, ngx_palloc(pool, sizeof(ngx_hunk_t)), NULL);
60 66
61 #if !(HAVE_OFFSET_EQUAL_PTR) 67 #if !(HAVE_OFFSET_EQUAL_PTR)
62 h->pos.file = h->last.file = 0; 68 h->pos.file = h->last.file = 0;
63 #endif 69 #endif
64 70
72 h->type = NGX_HUNK_TEMP; 78 h->type = NGX_HUNK_TEMP;
73 h->tag = 0; 79 h->tag = 0;
74 h->file = NULL; 80 h->file = NULL;
75 81
76 } else { 82 } else {
77 h->pre_start = h->start = h->pos.mem = h->last.mem = 83 ngx_test_null(h->pre_start, ngx_palloc(pool, size), NULL);
78 ngx_palloc(pool, size); 84 h->start = h->pos.mem = h->last.mem = h->pre_start;
79 h->end = h->post_end = h->start + size; 85 h->end = h->post_end = h->start + size;
80 86
81 h->type = NGX_HUNK_TEMP; 87 h->type = NGX_HUNK_TEMP;
82 h->tag = 0; 88 h->tag = 0;
83 h->file = NULL; 89 h->file = NULL;