comparison src/core/ngx_palloc.c @ 50:72eb30262aac NGINX_0_1_25

nginx 0.1.25 *) Bugfix: nginx did run on Linux parisc. *) Feature: nginx now does not start under FreeBSD if the sysctl kern.ipc.somaxconn value is too big. *) Bugfix: if a request was internally redirected by the ngx_http_index_module module to the ngx_http_proxy_module or ngx_http_fastcgi_module modules, then the index file was not closed after request completion. *) Feature: the "proxy_pass" can be used in location with regular expression. *) Feature: the ngx_http_rewrite_filter_module module supports the condition like "if ($HTTP_USER_AGENT ~ MSIE)". *) Bugfix: nginx started too slow if the large number of addresses and text values were used in the "geo" directive. *) Change: a variable name must be declared as "$name" in the "geo" directive. The previous variant without "$" is still supported, but will be removed soon. *) Feature: the "%{VARIABLE}v" logging parameter. *) Feature: the "set $name value" directive. *) Bugfix: gcc 4.0 compatibility. *) Feature: the --with-openssl-opt=OPTIONS autoconfiguration directive.
author Igor Sysoev <http://sysoev.ru>
date Sat, 19 Mar 2005 00:00:00 +0300
parents aab2ea7c0458
children 3050baa54a26
comparison
equal deleted inserted replaced
49:93dabbc9efb9 50:72eb30262aac
6 6
7 #include <ngx_config.h> 7 #include <ngx_config.h>
8 #include <ngx_core.h> 8 #include <ngx_core.h>
9 9
10 10
11 ngx_pool_t *ngx_create_pool(size_t size, ngx_log_t *log) 11 ngx_pool_t *
12 ngx_create_pool(size_t size, ngx_log_t *log)
12 { 13 {
13 ngx_pool_t *p; 14 ngx_pool_t *p;
14 15
15 if (!(p = ngx_alloc(size, log))) { 16 p = ngx_alloc(size, log);
17 if (p == NULL) {
16 return NULL; 18 return NULL;
17 } 19 }
18 20
19 p->last = (u_char *) p + sizeof(ngx_pool_t); 21 p->last = (u_char *) p + sizeof(ngx_pool_t);
20 p->end = (u_char *) p + size; 22 p->end = (u_char *) p + size;
24 26
25 return p; 27 return p;
26 } 28 }
27 29
28 30
29 void ngx_destroy_pool(ngx_pool_t *pool) 31 void
32 ngx_destroy_pool(ngx_pool_t *pool)
30 { 33 {
31 ngx_pool_t *p, *n; 34 ngx_pool_t *p, *n;
32 ngx_pool_large_t *l; 35 ngx_pool_large_t *l;
33 36
34 for (l = pool->large; l; l = l->next) { 37 for (l = pool->large; l; l = l->next) {
66 } 69 }
67 } 70 }
68 } 71 }
69 72
70 73
71 void *ngx_palloc(ngx_pool_t *pool, size_t size) 74 void *
75 ngx_palloc(ngx_pool_t *pool, size_t size)
72 { 76 {
73 u_char *m; 77 u_char *m;
74 ngx_pool_t *p, *n; 78 ngx_pool_t *p, *n;
75 ngx_pool_large_t *large, *last; 79 ngx_pool_large_t *large, *last;
76 80
92 } 96 }
93 } 97 }
94 98
95 /* allocate a new pool block */ 99 /* allocate a new pool block */
96 100
97 if (!(n = ngx_create_pool((size_t) (p->end - (u_char *) p), p->log))) { 101 n = ngx_create_pool((size_t) (p->end - (u_char *) p), p->log);
102 if (n == NULL) {
98 return NULL; 103 return NULL;
99 } 104 }
100 105
101 p->next = n; 106 p->next = n;
102 m = ngx_align(n->last); 107 m = ngx_align(n->last);
123 } 128 }
124 } 129 }
125 } 130 }
126 131
127 if (large == NULL) { 132 if (large == NULL) {
128 if (!(large = ngx_palloc(pool, sizeof(ngx_pool_large_t)))) { 133 large = ngx_palloc(pool, sizeof(ngx_pool_large_t));
134 if (large == NULL) {
129 return NULL; 135 return NULL;
130 } 136 }
131 137
132 large->next = NULL; 138 large->next = NULL;
133 } 139 }
134 140
135 #if 0 141 #if 0
136 if (!(p = ngx_memalign(ngx_pagesize, size, pool->log))) { 142 p = ngx_memalign(ngx_pagesize, size, pool->log);
143 if (p == NULL) {
137 return NULL; 144 return NULL;
138 } 145 }
139 #else 146 #else
140 if (!(p = ngx_alloc(size, pool->log))) { 147 p = ngx_alloc(size, pool->log);
148 if (p == NULL) {
141 return NULL; 149 return NULL;
142 } 150 }
143 #endif 151 #endif
144 152
145 if (pool->large == NULL) { 153 if (pool->large == NULL) {
153 161
154 return p; 162 return p;
155 } 163 }
156 164
157 165
158 ngx_int_t ngx_pfree(ngx_pool_t *pool, void *p) 166 ngx_int_t
167 ngx_pfree(ngx_pool_t *pool, void *p)
159 { 168 {
160 ngx_pool_large_t *l; 169 ngx_pool_large_t *l;
161 170
162 for (l = pool->large; l; l = l->next) { 171 for (l = pool->large; l; l = l->next) {
163 if (p == l->alloc) { 172 if (p == l->alloc) {
172 181
173 return NGX_DECLINED; 182 return NGX_DECLINED;
174 } 183 }
175 184
176 185
177 void *ngx_pcalloc(ngx_pool_t *pool, size_t size) 186 void *
187 ngx_pcalloc(ngx_pool_t *pool, size_t size)
178 { 188 {
179 void *p; 189 void *p;
180 190
181 p = ngx_palloc(pool, size); 191 p = ngx_palloc(pool, size);
182 if (p) { 192 if (p) {
186 return p; 196 return p;
187 } 197 }
188 198
189 #if 0 199 #if 0
190 200
191 static void *ngx_get_cached_block(size_t size) 201 static void *
202 ngx_get_cached_block(size_t size)
192 { 203 {
193 void *p; 204 void *p;
194 ngx_cached_block_slot_t *slot; 205 ngx_cached_block_slot_t *slot;
195 206
196 if (ngx_cycle->cache == NULL) { 207 if (ngx_cycle->cache == NULL) {