diff --git a/src/ds/bits.h b/src/ds/bits.h index 09dbf17..109eb26 100644 --- a/src/ds/bits.h +++ b/src/ds/bits.h @@ -454,9 +454,9 @@ namespace snmalloc } /** - * Implementation of std::min + * Implementation of `std::min` * - * std::min is algorithm, so pulls in a lot of unneccessary code + * `std::min` is in ``, so pulls in a lot of unneccessary code * We write our own to reduce the code that potentially needs reviewing. **/ template @@ -466,9 +466,9 @@ namespace snmalloc } /** - * Implementation of std::max + * Implementation of `std::max` * - * std::max is algorithm, so pulls in a lot of unneccessary code + * `std::max` is in ``, so pulls in a lot of unneccessary code * We write our own to reduce the code that potentially needs reviewing. **/ template diff --git a/src/ds/dllist.h b/src/ds/dllist.h index 80df626..a831e5a 100644 --- a/src/ds/dllist.h +++ b/src/ds/dllist.h @@ -6,7 +6,7 @@ namespace snmalloc { - template + template class DLList { private: @@ -15,7 +15,7 @@ namespace snmalloc // constexpr. static inline T* terminator() { - return (T*)terminator_; + return (T*)Terminator; } static_assert( @@ -26,6 +26,11 @@ namespace snmalloc T* head = terminator(); public: + bool is_empty() + { + return head == terminator(); + } + T* get_head() { return head; diff --git a/src/mem/alloc.h b/src/mem/alloc.h index 8365745..52b7379 100644 --- a/src/mem/alloc.h +++ b/src/mem/alloc.h @@ -984,11 +984,11 @@ namespace snmalloc stats().sizeclass_alloc(sizeclass); SlabList* sc = &small_classes[sizeclass]; - SlabLink* link = sc->get_head(); Slab* slab; - if (~(uintptr_t)link != 0) + if (!sc->is_empty()) { + SlabLink* link = sc->get_head(); slab = link->get_slab(); } else diff --git a/src/mem/pagemap.h b/src/mem/pagemap.h index a204c59..c9c12ef 100644 --- a/src/mem/pagemap.h +++ b/src/mem/pagemap.h @@ -51,8 +51,6 @@ namespace snmalloc private: static constexpr size_t COVERED_BITS = bits::ADDRESS_BITS - GRANULARITY_BITS; - static constexpr size_t POINTER_BITS = - bits::next_pow2_bits_const(sizeof(void*)); static constexpr size_t CONTENT_BITS = bits::next_pow2_bits_const(sizeof(T));