comparison src/core/ngx_array.c @ 2049:2a92804f4109

*) back out r2040 *) refactor ngx_palloc() *) introduce ngx_pnalloc() *) additional pool blocks have smaller header
author Igor Sysoev <igor@sysoev.ru>
date Tue, 17 Jun 2008 15:00:30 +0000
parents 5dac8c7fb71b
children d620f497c50f
comparison
equal deleted inserted replaced
2048:824615f3b4ec 2049:2a92804f4109
37 { 37 {
38 ngx_pool_t *p; 38 ngx_pool_t *p;
39 39
40 p = a->pool; 40 p = a->pool;
41 41
42 if ((u_char *) a->elts + a->size * a->nalloc == p->last) { 42 if ((u_char *) a->elts + a->size * a->nalloc == p->d.last) {
43 p->last -= a->size * a->nalloc; 43 p->d.last -= a->size * a->nalloc;
44 } 44 }
45 45
46 if ((u_char *) a + sizeof(ngx_array_t) == p->last) { 46 if ((u_char *) a + sizeof(ngx_array_t) == p->d.last) {
47 p->last = (u_char *) a; 47 p->d.last = (u_char *) a;
48 } 48 }
49 } 49 }
50 50
51 51
52 void * 52 void *
62 62
63 size = a->size * a->nalloc; 63 size = a->size * a->nalloc;
64 64
65 p = a->pool; 65 p = a->pool;
66 66
67 if ((u_char *) a->elts + size == p->last && p->last + a->size <= p->end) 67 if ((u_char *) a->elts + size == p->d.last
68 && p->d.last + a->size <= p->d.end)
68 { 69 {
69 /* 70 /*
70 * the array allocation is the last in the pool 71 * the array allocation is the last in the pool
71 * and there is space for new allocation 72 * and there is space for new allocation
72 */ 73 */
73 74
74 p->last += a->size; 75 p->d.last += a->size;
75 a->nalloc++; 76 a->nalloc++;
76 77
77 } else { 78 } else {
78 /* allocate a new array */ 79 /* allocate a new array */
79 80
109 110
110 /* the array is full */ 111 /* the array is full */
111 112
112 p = a->pool; 113 p = a->pool;
113 114
114 if ((u_char *) a->elts + a->size * a->nalloc == p->last 115 if ((u_char *) a->elts + a->size * a->nalloc == p->d.last
115 && p->last + size <= p->end) 116 && p->d.last + size <= p->d.end)
116 { 117 {
117 /* 118 /*
118 * the array allocation is the last in the pool 119 * the array allocation is the last in the pool
119 * and there is space for new allocation 120 * and there is space for new allocation
120 */ 121 */
121 122
122 p->last += size; 123 p->d.last += size;
123 a->nalloc += n; 124 a->nalloc += n;
124 125
125 } else { 126 } else {
126 /* allocate a new array */ 127 /* allocate a new array */
127 128