From 14311536959457d10e9307a580afeb0af1a8838b Mon Sep 17 00:00:00 2001 From: Kevin Svetlitski Date: Mon, 24 Jul 2023 10:36:32 -0700 Subject: [PATCH] Define `SBRK_INVALID` instead of using a magic number --- src/extent_dss.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/extent_dss.c b/src/extent_dss.c index 0b846296..f8bd8f60 100644 --- a/src/extent_dss.c +++ b/src/extent_dss.c @@ -8,6 +8,8 @@ /******************************************************************************/ /* Data. */ +#define SBRK_INVALID ((void *)-1) + const char *opt_dss = DSS_DEFAULT; const char *const dss_prec_names[] = { @@ -94,7 +96,7 @@ extent_dss_max_update(void *new_addr) { * up to date. */ void *max_cur = extent_dss_sbrk(0); - if (max_cur == (void *)-1) { + if (max_cur == SBRK_INVALID) { return NULL; } atomic_store_p(&dss_max, max_cur, ATOMIC_RELEASE); @@ -220,7 +222,7 @@ extent_alloc_dss(tsdn_t *tsdn, arena_t *arena, void *new_addr, size_t size, * Failure, whether due to OOM or a race with a raw * sbrk() call from outside the allocator. */ - if (dss_prev == (void *)-1) { + if (dss_prev == SBRK_INVALID) { /* OOM. */ atomic_store_b(&dss_exhausted, true, ATOMIC_RELEASE); @@ -270,7 +272,7 @@ extent_dss_boot(void) { dss_base = extent_dss_sbrk(0); atomic_store_b(&dss_extending, false, ATOMIC_RELAXED); - atomic_store_b(&dss_exhausted, dss_base == (void *)-1, ATOMIC_RELAXED); + atomic_store_b(&dss_exhausted, dss_base == SBRK_INVALID, ATOMIC_RELAXED); atomic_store_p(&dss_max, dss_base, ATOMIC_RELAXED); }