This commit is contained in:
Matthew Parkinson
2019-04-26 16:32:39 +01:00
committed by Matthew Parkinson
parent 8eb6e36966
commit c471e1a271
4 changed files with 13 additions and 10 deletions

View File

@@ -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 `<algorithm>`, so pulls in a lot of unneccessary code
* We write our own to reduce the code that potentially needs reviewing.
**/
template<typename T>
@@ -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 `<algorithm>`, so pulls in a lot of unneccessary code
* We write our own to reduce the code that potentially needs reviewing.
**/
template<typename T>

View File

@@ -6,7 +6,7 @@
namespace snmalloc
{
template<class T, uintptr_t terminator_ = 0>
template<class T, uintptr_t Terminator = 0>
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;

View File

@@ -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

View File

@@ -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));