summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_array.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2017-06-20 19:49:17 +0300
committerIgor Sysoev <igor@sysoev.ru>2017-06-20 19:49:17 +0300
commitf888a5310c1808902b4035ca3454b62bc5cf4434 (patch)
tree7425e11cdba27420d21468b0f79787834bd3c498 /src/nxt_array.c
parentc7ab908c19242a5ddd0233e123e8c2be210b3c02 (diff)
downloadunit-f888a5310c1808902b4035ca3454b62bc5cf4434.tar.gz
unit-f888a5310c1808902b4035ca3454b62bc5cf4434.tar.bz2
Using new memory pool implementation.
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;
}