Mercurial > hg > nginx-quic
diff src/core/ngx_buf.c @ 343:6bdf858bff8c
nginx-0.0.3-2004-05-28-19:49:23 import; rename ngx_hunk_t to ngx_buf_t
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 28 May 2004 15:49:23 +0000 |
parents | src/core/ngx_hunk.c@87e73f067470 |
children | 2e3cbc1bbe3c |
line wrap: on
line diff
copy from src/core/ngx_hunk.c copy to src/core/ngx_buf.c --- a/src/core/ngx_hunk.c +++ b/src/core/ngx_buf.c @@ -3,63 +3,77 @@ #include <ngx_core.h> -ngx_hunk_t *ngx_create_temp_hunk(ngx_pool_t *pool, size_t size) +ngx_buf_t *ngx_create_temp_buf(ngx_pool_t *pool, size_t size) { - ngx_hunk_t *h; + ngx_buf_t *b; - ngx_test_null(h, ngx_alloc_hunk(pool), NULL); + if (!(b = ngx_calloc_buf(pool))) { + return NULL; + } - ngx_test_null(h->start, ngx_palloc(pool, size), NULL); - - h->pos = h->start; - h->last = h->start; + if (!(b->start = ngx_palloc(pool, size))) { + return NULL; + } - h->file_pos = 0; - h->file_last = 0; - - h->end = h->last + size; + b->pos = b->start; + b->last = b->start; + b->end = b->last + size; + b->temporary = 1; - h->type = NGX_HUNK_TEMP|NGX_HUNK_IN_MEMORY; - h->file = NULL; - h->shadow = NULL; + /* + b->file_pos = 0; + b->file_last = 0; - h->tag = 0; + b->file = NULL; + b->shadow = NULL; - return h; + b->tag = 0; + */ + + return b; } -ngx_chain_t *ngx_create_chain_of_hunks(ngx_pool_t *pool, ngx_bufs_t *bufs) +ngx_chain_t *ngx_create_chain_of_bufs(ngx_pool_t *pool, ngx_bufs_t *bufs) { + u_char *p; ngx_int_t i; - u_char *p; - ngx_hunk_t *h; + ngx_buf_t *b; ngx_chain_t *chain, *cl, **ll; - ngx_test_null(p, ngx_palloc(pool, bufs->num * bufs->size), NULL); + if (!(p = ngx_palloc(pool, bufs->num * bufs->size))) { + return NULL; + } ll = &chain; for (i = 0; i < bufs->num; i++) { - ngx_test_null(h, ngx_alloc_hunk(pool), NULL); + if (!(b = ngx_calloc_buf(pool))) { + return NULL; + } - h->pos = p; - h->last = p; - h->file_pos = 0; - h->file_last = 0; + b->pos = p; + b->last = p; + b->temporary = 1; - h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_TEMP; + b->start = p; + p += bufs->size; + b->end = p; - h->start = p; - p += bufs->size; - h->end = p; + /* + b->file_pos = 0; + b->file_last = 0; - h->file = NULL; - h->shadow = NULL; - h->tag = 0; + b->file = NULL; + b->shadow = NULL; + b->tag = 0; + */ - ngx_test_null(cl, ngx_alloc_chain_link(pool), NULL); - cl->hunk = h; + if (!(cl = ngx_alloc_chain_link(pool))) { + return NULL; + } + + cl->buf = b; *ll = cl; ll = &cl->next; } @@ -83,7 +97,7 @@ int ngx_chain_add_copy(ngx_pool_t *pool, while (in) { ngx_test_null(cl, ngx_alloc_chain_link(pool), NGX_ERROR); - cl->hunk = in->hunk; + cl->buf = in->buf; *ll = cl; ll = &cl->next; in = in->next; @@ -96,7 +110,7 @@ int ngx_chain_add_copy(ngx_pool_t *pool, void ngx_chain_update_chains(ngx_chain_t **free, ngx_chain_t **busy, - ngx_chain_t **out, ngx_hunk_tag_t tag) + ngx_chain_t **out, ngx_buf_tag_t tag) { ngx_chain_t *tl; @@ -115,22 +129,22 @@ void ngx_chain_update_chains(ngx_chain_t *out = NULL; while (*busy) { - if (ngx_hunk_size((*busy)->hunk) != 0) { + if (ngx_buf_size((*busy)->buf) != 0) { break; } #if (HAVE_WRITE_ZEROCOPY) - if ((*busy)->hunk->type & NGX_HUNK_ZEROCOPY_BUSY) { + if ((*busy)->buf->zerocopy_busy) { break; } #endif - if ((*busy)->hunk->tag != tag) { + if ((*busy)->buf->tag != tag) { *busy = (*busy)->next; continue; } - (*busy)->hunk->pos = (*busy)->hunk->last = (*busy)->hunk->start; + (*busy)->buf->pos = (*busy)->buf->last = (*busy)->buf->start; tl = *busy; *busy = (*busy)->next;