Back to home page

Nginx displayed by LXR

Source navigation ]
Diff markup ]
Identifier search ]
general search ]
 
 
Version: nginx-1.13.12 ]​[ nginx-1.12.2 ]​

0001 
0002 /*
0003  * Copyright (C) Igor Sysoev
0004  * Copyright (C) Nginx, Inc.
0005  */
0006 
0007 
0008 #ifndef _NGX_ARRAY_H_INCLUDED_
0009 #define _NGX_ARRAY_H_INCLUDED_
0010 
0011 
0012 #include <ngx_config.h>
0013 #include <ngx_core.h>
0014 
0015 
0016 typedef struct {
0017     void        *elts;
0018     ngx_uint_t   nelts;
0019     size_t       size;
0020     ngx_uint_t   nalloc;
0021     ngx_pool_t  *pool;
0022 } ngx_array_t;
0023 
0024 
0025 ngx_array_t *ngx_array_create(ngx_pool_t *p, ngx_uint_t n, size_t size);
0026 void ngx_array_destroy(ngx_array_t *a);
0027 void *ngx_array_push(ngx_array_t *a);
0028 void *ngx_array_push_n(ngx_array_t *a, ngx_uint_t n);
0029 
0030 
0031 static ngx_inline ngx_int_t
0032 ngx_array_init(ngx_array_t *array, ngx_pool_t *pool, ngx_uint_t n, size_t size)
0033 {
0034     /*
0035      * set "array->nelts" before "array->elts", otherwise MSVC thinks
0036      * that "array->nelts" may be used without having been initialized
0037      */
0038 
0039     array->nelts = 0;
0040     array->size = size;
0041     array->nalloc = n;
0042     array->pool = pool;
0043 
0044     array->elts = ngx_palloc(pool, n * size);
0045     if (array->elts == NULL) {
0046         return NGX_ERROR;
0047     }
0048 
0049     return NGX_OK;
0050 }
0051 
0052 
0053 #endif /* _NGX_ARRAY_H_INCLUDED_ */