Using new memory pool implementation.

This commit is contained in:
Igor Sysoev
2017-06-20 19:49:17 +03:00
parent c7ab908c19
commit f888a5310c
72 changed files with 350 additions and 1326 deletions

View File

@@ -8,12 +8,12 @@
nxt_str_t *
nxt_str_alloc(nxt_mem_pool_t *mp, size_t length)
nxt_str_alloc(nxt_mp_t *mp, size_t length)
{
nxt_str_t *s;
/* The string start is allocated aligned to be close to nxt_str_t. */
s = nxt_mem_alloc(mp, sizeof(nxt_str_t) + length);
s = nxt_mp_get(mp, sizeof(nxt_str_t) + length);
if (nxt_fast_path(s != NULL)) {
s->length = length;
@@ -31,13 +31,13 @@ nxt_str_alloc(nxt_mem_pool_t *mp, size_t length)
*/
nxt_str_t *
nxt_str_dup(nxt_mem_pool_t *mp, nxt_str_t *dst, const nxt_str_t *src)
nxt_str_dup(nxt_mp_t *mp, nxt_str_t *dst, const nxt_str_t *src)
{
u_char *p;
if (dst == NULL) {
/* The string start is allocated aligned to be close to nxt_str_t. */
dst = nxt_mem_alloc(mp, sizeof(nxt_str_t) + src->length);
dst = nxt_mp_get(mp, sizeof(nxt_str_t) + src->length);
if (nxt_slow_path(dst == NULL)) {
return NULL;
}
@@ -47,7 +47,7 @@ nxt_str_dup(nxt_mem_pool_t *mp, nxt_str_t *dst, const nxt_str_t *src)
dst->start = p;
} else {
dst->start = nxt_mem_nalloc(mp, src->length);
dst->start = nxt_mp_nget(mp, src->length);
if (nxt_slow_path(dst->start == NULL)) {
return NULL;
}
@@ -69,11 +69,11 @@ nxt_str_dup(nxt_mem_pool_t *mp, nxt_str_t *dst, const nxt_str_t *src)
*/
char *
nxt_str_copy(nxt_mem_pool_t *mp, const nxt_str_t *src)
nxt_str_copy(nxt_mp_t *mp, const nxt_str_t *src)
{
char *p, *dst;
dst = nxt_mem_align(mp, 2, src->length + 1);
dst = nxt_mp_align(mp, 2, src->length + 1);
if (nxt_fast_path(dst != NULL)) {
p = nxt_cpymem(dst, src->start, src->length);