summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_array.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nxt_array.c')
-rw-r--r--src/nxt_array.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/nxt_array.c b/src/nxt_array.c
index 69e59c67..d7bc28bd 100644
--- a/src/nxt_array.c
+++ b/src/nxt_array.c
@@ -8,11 +8,11 @@
nxt_array_t *
-nxt_array_create(nxt_mem_pool_t *mp, nxt_uint_t n, size_t size)
+nxt_array_create(nxt_mp_t *mp, nxt_uint_t n, size_t size)
{
nxt_array_t *array;
- array = nxt_mem_alloc(mp, sizeof(nxt_array_t) + n * size);
+ array = nxt_mp_alloc(mp, sizeof(nxt_array_t) + n * size);
if (nxt_slow_path(array == NULL)) {
return NULL;
@@ -47,7 +47,7 @@ nxt_array_add(nxt_array_t *array)
new_alloc = nalloc + nalloc / 2;
}
- p = nxt_mem_alloc(array->mem_pool, array->size * new_alloc);
+ p = nxt_mp_alloc(array->mem_pool, array->size * new_alloc);
if (nxt_slow_path(p == NULL)) {
return NULL;
@@ -55,6 +55,8 @@ nxt_array_add(nxt_array_t *array)
nxt_memcpy(p, array->elts, array->size * nalloc);
+ nxt_mp_free(array->mem_pool, array->elts);
+
array->elts = p;
array->nalloc = new_alloc;
}