diff options
author | Igor Sysoev <igor@sysoev.ru> | 2017-12-28 16:01:06 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2017-12-28 16:01:06 +0300 |
commit | 497faf1b9abb188cab40c389a9e6221add5dd496 (patch) | |
tree | cb25d7f278a6706cf6f74cd25982764ca1d0c4f6 /src/nxt_mp.c | |
parent | b59535b22c73b04ed85c0bc1287203e3449c645b (diff) | |
download | unit-497faf1b9abb188cab40c389a9e6221add5dd496.tar.gz unit-497faf1b9abb188cab40c389a9e6221add5dd496.tar.bz2 |
Changed nxt_mp_retain() and nxt_mp_release() interfaces.
Diffstat (limited to 'src/nxt_mp.c')
-rw-r--r-- | src/nxt_mp.c | 59 |
1 files changed, 22 insertions, 37 deletions
diff --git a/src/nxt_mp.c b/src/nxt_mp.c index 8c2da262..776c96b2 100644 --- a/src/nxt_mp.c +++ b/src/nxt_mp.c @@ -282,6 +282,28 @@ nxt_mp_create(size_t cluster_size, size_t page_alignment, size_t page_size, void +nxt_mp_retain(nxt_mp_t *mp) +{ + mp->retain++; + + nxt_thread_log_debug("mp %p retain: %uD", mp, mp->retain); +} + + +void +nxt_mp_release(nxt_mp_t *mp) +{ + mp->retain--; + + nxt_thread_log_debug("mp %p release: %uD", mp, mp->retain); + + if (mp->retain == 0) { + nxt_mp_destroy(mp); + } +} + + +void nxt_mp_destroy(nxt_mp_t *mp) { void *p; @@ -934,43 +956,6 @@ nxt_mp_chunk_free(nxt_mp_t *mp, nxt_mp_block_t *cluster, u_char *p) void * -nxt_mp_retain(nxt_mp_t *mp, size_t size) -{ - void *p; - - p = nxt_mp_alloc(mp, size); - - if (nxt_fast_path(p != NULL)) { - mp->retain++; - nxt_debug_alloc("mp %p retain: %uD", mp, mp->retain); - } - - return p; -} - - -uint32_t -nxt_mp_release(nxt_mp_t *mp, void *p) -{ - if (nxt_fast_path(p != NULL)) { - nxt_mp_free(mp, p); - } - - mp->retain--; - - nxt_debug_alloc("mp %p release: %uD", mp, mp->retain); - - if (mp->retain == 0) { - nxt_mp_destroy(mp); - - return 0; - } - - return mp->retain; -} - - -void * nxt_mp_nget(nxt_mp_t *mp, size_t size) { void *p; |