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.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/nxt_array.c b/src/nxt_array.c
index f26670f5..82019f92 100644
--- a/src/nxt_array.c
+++ b/src/nxt_array.c
@@ -28,6 +28,17 @@ nxt_array_create(nxt_mp_t *mp, nxt_uint_t n, size_t size)
}
+void
+nxt_array_destroy(nxt_array_t *array)
+{
+ if (array->elts != nxt_pointer_to(array, sizeof(nxt_array_t))) {
+ nxt_mp_free(array->mem_pool, array->elts);
+ }
+
+ nxt_mp_free(array->mem_pool, array);
+}
+
+
void *
nxt_array_add(nxt_array_t *array)
{
@@ -55,7 +66,9 @@ nxt_array_add(nxt_array_t *array)
nxt_memcpy(p, array->elts, array->size * nalloc);
- nxt_mp_free(array->mem_pool, array->elts);
+ if (array->elts != nxt_pointer_to(array, sizeof(nxt_array_t))) {
+ nxt_mp_free(array->mem_pool, array->elts);
+ }
array->elts = p;
array->nalloc = new_alloc;