Mercurial > hg > nginx
comparison src/core/ngx_palloc.c @ 436:9549fc9508e5
nginx-0.0.11-2004-09-23-10:32:00 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 23 Sep 2004 06:32:00 +0000 |
parents | 694cd6cdb714 |
children | da8c5707af39 |
comparison
equal
deleted
inserted
replaced
435:5cdc4838d4e8 | 436:9549fc9508e5 |
---|---|
42 * we could allocate the pool->log from this pool | 42 * we could allocate the pool->log from this pool |
43 * so we can not use this log while the free()ing the pool | 43 * so we can not use this log while the free()ing the pool |
44 */ | 44 */ |
45 | 45 |
46 for (p = pool, n = pool->next; /* void */; p = n, n = n->next) { | 46 for (p = pool, n = pool->next; /* void */; p = n, n = n->next) { |
47 ngx_log_debug1(NGX_LOG_DEBUG_ALLOC, pool->log, 0, | 47 ngx_log_debug2(NGX_LOG_DEBUG_ALLOC, pool->log, 0, |
48 "free: " PTR_FMT, p); | 48 "free: " PTR_FMT ", unused: " SIZE_T_FMT, |
49 p, p->end - p->last); | |
49 | 50 |
50 if (n == NULL) { | 51 if (n == NULL) { |
51 break; | 52 break; |
52 } | 53 } |
53 } | 54 } |
69 char *m; | 70 char *m; |
70 ngx_pool_t *p, *n; | 71 ngx_pool_t *p, *n; |
71 ngx_pool_large_t *large, *last; | 72 ngx_pool_large_t *large, *last; |
72 | 73 |
73 if (size <= (size_t) NGX_MAX_ALLOC_FROM_POOL | 74 if (size <= (size_t) NGX_MAX_ALLOC_FROM_POOL |
74 && size <= (size_t) (pool->end - (char *) pool)) | 75 && size <= (size_t) (pool->end - (char *) pool) - sizeof(ngx_pool_t)) |
75 { | 76 { |
76 for (p = pool, n = pool->next; /* void */; p = n, n = n->next) { | 77 for (p = pool, n = pool->next; /* void */; p = n, n = n->next) { |
77 m = ngx_align(p->last); | 78 m = ngx_align(p->last); |
78 | 79 |
79 if ((size_t) (p->end - m) >= size) { | 80 if ((size_t) (p->end - m) >= size) { |
104 | 105 |
105 large = NULL; | 106 large = NULL; |
106 last = NULL; | 107 last = NULL; |
107 | 108 |
108 if (pool->large) { | 109 if (pool->large) { |
109 for (last = pool->large; /* void */; last = last->next) { | 110 for (last = pool->large; /* void */ ; last = last->next) { |
110 if (last->alloc == NULL) { | 111 if (last->alloc == NULL) { |
111 large = last; | 112 large = last; |
112 last = NULL; | 113 last = NULL; |
113 break; | 114 break; |
114 } | 115 } |
148 | 149 |
149 return p; | 150 return p; |
150 } | 151 } |
151 | 152 |
152 | 153 |
153 void ngx_pfree(ngx_pool_t *pool, void *p) | 154 ngx_int_t ngx_pfree(ngx_pool_t *pool, void *p) |
154 { | 155 { |
155 ngx_pool_large_t *l; | 156 ngx_pool_large_t *l; |
156 | 157 |
157 for (l = pool->large; l; l = l->next) { | 158 for (l = pool->large; l; l = l->next) { |
158 if (p == l->alloc) { | 159 if (p == l->alloc) { |
159 ngx_log_debug1(NGX_LOG_DEBUG_ALLOC, pool->log, 0, | 160 ngx_log_debug1(NGX_LOG_DEBUG_ALLOC, pool->log, 0, |
160 "free: " PTR_FMT, l->alloc); | 161 "free: " PTR_FMT, l->alloc); |
161 free(l->alloc); | 162 free(l->alloc); |
162 l->alloc = NULL; | 163 l->alloc = NULL; |
163 } | 164 |
164 } | 165 return NGX_OK; |
166 } | |
167 } | |
168 | |
169 return NGX_DECLINED; | |
165 } | 170 } |
166 | 171 |
167 | 172 |
168 void *ngx_pcalloc(ngx_pool_t *pool, size_t size) | 173 void *ngx_pcalloc(ngx_pool_t *pool, size_t size) |
169 { | 174 { |