2323#include < sys/mman.h>
2424
2525#include < chrono>
26- #include < memory>
2726#include < stdexcept>
2827
2928#include " cachelib/common/Utils.h"
@@ -341,7 +340,7 @@ Slab* SlabAllocator::makeNewSlabImpl() {
341340void SlabAllocator::initializeHeader (Slab* slab, PoolId id) {
342341 auto * header = getSlabHeader (slab);
343342 XDCHECK (header != nullptr );
344- header = new (header) SlabHeader (id);
343+ new (header) SlabHeader (id);
345344}
346345
347346Slab* SlabAllocator::makeNewSlab (PoolId id) {
@@ -461,8 +460,8 @@ std::tuple<uint32_t, const void*> SlabAllocator::getRandomAlloc()
461460
462461 // pick a random location in the memory.
463462 const auto offset = folly::Random::rand64 (0 , validMaxOffset);
464- const auto * memory = reinterpret_cast < void *>(
465- reinterpret_cast <uintptr_t >(slabMemoryStart_) + offset) ;
463+ const auto * memory =
464+ reinterpret_cast <const uint8_t * >(slabMemoryStart_) + offset;
466465
467466 const auto * slab = getSlabForMemory (memory);
468467 const auto * header = getSlabHeader (slab);
@@ -484,8 +483,7 @@ std::tuple<uint32_t, const void*> SlabAllocator::getRandomAlloc()
484483 allocSize;
485484 allocIdx = allocIdx > maxAllocIdx ? maxAllocIdx : allocIdx;
486485 return std::make_tuple (
487- allocSize, reinterpret_cast <const void *>(
488- reinterpret_cast <uintptr_t >(slab) + allocSize * allocIdx));
486+ allocSize, reinterpret_cast <const uint8_t *>(slab) + allocSize * allocIdx);
489487}
490488
491489serialization::SlabAllocatorObject SlabAllocator::saveState () {
0 commit comments