summaryrefslogtreecommitdiff
path: root/src/core/ngx_array.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/ngx_array.h')
-rw-r--r--src/core/ngx_array.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/core/ngx_array.h b/src/core/ngx_array.h
index 5f97451aa..00206cb1b 100644
--- a/src/core/ngx_array.h
+++ b/src/core/ngx_array.h
@@ -30,16 +30,21 @@ void *ngx_array_push_n(ngx_array_t *a, ngx_uint_t n);
static ngx_inline ngx_int_t
ngx_array_init(ngx_array_t *array, ngx_pool_t *pool, ngx_uint_t n, size_t size)
{
- array->elts = ngx_palloc(pool, n * size);
- if (array->elts == NULL) {
- return NGX_ERROR;
- }
+ /*
+ * set "array->nelts" before "array->elts", otherwise MSVC thinks
+ * that "array->nelts" may be used without having been initialized
+ */
array->nelts = 0;
array->size = size;
array->nalloc = n;
array->pool = pool;
+ array->elts = ngx_palloc(pool, n * size);
+ if (array->elts == NULL) {
+ return NGX_ERROR;
+ }
+
return NGX_OK;
}