3 * Copyright (C) Igor Sysoev
4 * Copyright (C) Nginx, Inc.
8 #include <ngx_config.h>
13 ngx_create_temp_buf(ngx_pool_t
*pool
, size_t size
)
17 b
= ngx_calloc_buf(pool
);
22 b
->start
= ngx_palloc(pool
, size
);
23 if (b
->start
== NULL
) {
28 * set by ngx_calloc_buf():
40 b
->end
= b
->last
+ size
;
48 ngx_alloc_chain_link(ngx_pool_t
*pool
)
55 pool
->chain
= cl
->next
;
59 cl
= ngx_palloc(pool
, sizeof(ngx_chain_t
));
69 ngx_create_chain_of_bufs(ngx_pool_t
*pool
, ngx_bufs_t
*bufs
)
74 ngx_chain_t
*chain
, *cl
, **ll
;
76 p
= ngx_palloc(pool
, bufs
->num
* bufs
->size
);
83 for (i
= 0; i
< bufs
->num
; i
++) {
85 b
= ngx_calloc_buf(pool
);
91 * set by ngx_calloc_buf():
110 cl
= ngx_alloc_chain_link(pool
);
127 ngx_chain_add_copy(ngx_pool_t
*pool
, ngx_chain_t
**chain
, ngx_chain_t
*in
)
129 ngx_chain_t
*cl
, **ll
;
133 for (cl
= *chain
; cl
; cl
= cl
->next
) {
138 cl
= ngx_alloc_chain_link(pool
);
156 ngx_chain_get_free_buf(ngx_pool_t
*p
, ngx_chain_t
**free
)
167 cl
= ngx_alloc_chain_link(p
);
172 cl
->buf
= ngx_calloc_buf(p
);
173 if (cl
->buf
== NULL
) {
184 ngx_chain_update_chains(ngx_pool_t
*p
, ngx_chain_t
**free
, ngx_chain_t
**busy
,
185 ngx_chain_t
**out
, ngx_buf_tag_t tag
)
193 for (cl
= *busy
; cl
->next
; cl
= cl
->next
) { /* void */ }
203 if (ngx_buf_size(cl
->buf
) != 0) {
207 if (cl
->buf
->tag
!= tag
) {
209 ngx_free_chain(p
, cl
);
213 cl
->buf
->pos
= cl
->buf
->start
;
214 cl
->buf
->last
= cl
->buf
->start
;