diff options
author | Max Romanov <max.romanov@nginx.com> | 2017-07-12 20:32:22 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@nginx.com> | 2017-07-12 20:32:22 +0300 |
commit | 288fa854315067b66cc5926222e0bfb5942147a2 (patch) | |
tree | 205147b5a5b27792f4bcb34274e27123ac86024f /src/nxt_array.c | |
parent | 48afadfe7c617991cefc289e0200bfbbadecdbb9 (diff) | |
download | unit-288fa854315067b66cc5926222e0bfb5942147a2.tar.gz unit-288fa854315067b66cc5926222e0bfb5942147a2.tar.bz2 |
Array elements reallocation fixed.
Diffstat (limited to 'src/nxt_array.c')
-rw-r--r-- | src/nxt_array.c | 15 |
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; |