You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-07 03:22:57 +03:00
Reformat all code to coding standard
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
|
||||
/* This allocator is for frequent small allocations that all get deallocated at once.
|
||||
It allocates large blocks of memory from the system and distributes 'allocsize'
|
||||
units to the caller. When the large allocation is used up, it will allocate
|
||||
units to the caller. When the large allocation is used up, it will allocate
|
||||
more unless the 'tmpspace' flag is set. If it is, it will reuse the memory it
|
||||
already allocated. This is useful for short-lived vars that are guaranteed to be
|
||||
out of scope by the time the allocator wraps around.
|
||||
@@ -45,49 +45,50 @@
|
||||
#define EXPORT
|
||||
#endif
|
||||
|
||||
namespace utils {
|
||||
namespace utils
|
||||
{
|
||||
|
||||
class FixedAllocator
|
||||
{
|
||||
public:
|
||||
EXPORT static const unsigned long DEFAULT_NUM_ELEMENTS=(4096 * 4); // should be a multiple of pagesize
|
||||
EXPORT static const unsigned long DEFAULT_NUM_ELEMENTS = (4096 * 4); // should be a multiple of pagesize
|
||||
|
||||
EXPORT FixedAllocator() :
|
||||
capacityRemaining(0),
|
||||
elementCount(std::numeric_limits<unsigned long>::max()),
|
||||
elementSize(0),
|
||||
currentlyStored(0),
|
||||
tmpSpace(false),
|
||||
nextAlloc(0) {}
|
||||
EXPORT explicit FixedAllocator(unsigned long allocSize, bool isTmpSpace = false,
|
||||
unsigned long numElements = DEFAULT_NUM_ELEMENTS) :
|
||||
capacityRemaining(0),
|
||||
elementCount(numElements),
|
||||
elementSize(allocSize),
|
||||
currentlyStored(0),
|
||||
tmpSpace(isTmpSpace),
|
||||
nextAlloc(0) {}
|
||||
EXPORT FixedAllocator(const FixedAllocator &);
|
||||
EXPORT FixedAllocator & operator=(const FixedAllocator &);
|
||||
virtual ~FixedAllocator() {}
|
||||
EXPORT FixedAllocator() :
|
||||
capacityRemaining(0),
|
||||
elementCount(std::numeric_limits<unsigned long>::max()),
|
||||
elementSize(0),
|
||||
currentlyStored(0),
|
||||
tmpSpace(false),
|
||||
nextAlloc(0) {}
|
||||
EXPORT explicit FixedAllocator(unsigned long allocSize, bool isTmpSpace = false,
|
||||
unsigned long numElements = DEFAULT_NUM_ELEMENTS) :
|
||||
capacityRemaining(0),
|
||||
elementCount(numElements),
|
||||
elementSize(allocSize),
|
||||
currentlyStored(0),
|
||||
tmpSpace(isTmpSpace),
|
||||
nextAlloc(0) {}
|
||||
EXPORT FixedAllocator(const FixedAllocator&);
|
||||
EXPORT FixedAllocator& operator=(const FixedAllocator&);
|
||||
virtual ~FixedAllocator() {}
|
||||
|
||||
EXPORT void* allocate();
|
||||
EXPORT void* allocate(uint32_t len); // a hack to make it work more like a pool allocator (use PoolAllocator instead)
|
||||
EXPORT void truncateBy(uint32_t amt); // returns a portion of mem just allocated; use with caution
|
||||
void deallocate() { } // does nothing
|
||||
EXPORT void deallocateAll(); // drops all memory in use
|
||||
EXPORT uint64_t getMemUsage() const;
|
||||
|
||||
EXPORT void * allocate();
|
||||
EXPORT void * allocate(uint32_t len); // a hack to make it work more like a pool allocator (use PoolAllocator instead)
|
||||
EXPORT void truncateBy(uint32_t amt); // returns a portion of mem just allocated; use with caution
|
||||
void deallocate() { } // does nothing
|
||||
EXPORT void deallocateAll(); // drops all memory in use
|
||||
EXPORT uint64_t getMemUsage() const;
|
||||
|
||||
private:
|
||||
void newBlock();
|
||||
void newBlock();
|
||||
|
||||
std::vector<boost::shared_array<uint8_t> > mem;
|
||||
unsigned long capacityRemaining;
|
||||
uint64_t elementCount;
|
||||
unsigned long elementSize;
|
||||
uint64_t currentlyStored;
|
||||
bool tmpSpace;
|
||||
uint8_t* nextAlloc;
|
||||
std::vector<boost::shared_array<uint8_t> > mem;
|
||||
unsigned long capacityRemaining;
|
||||
uint64_t elementCount;
|
||||
unsigned long elementSize;
|
||||
uint64_t currentlyStored;
|
||||
bool tmpSpace;
|
||||
uint8_t* nextAlloc;
|
||||
};
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user