6 #ifndef SLAB_ALLOCATOR_CC
7 #define SLAB_ALLOCATOR_CC
19 #include <sys/socket.h>
20 #include <sys/signal.h>
21 #include <sys/resource.h>
23 #include <netinet/in.h>
35 if (this->opt4hashmap ==
true) {
66 if (this->opt4hashmap ==
true) {
116 "Warning: Failed to allocate requested memory in"
117 " one large chunk.\nWill allocate in smaller chunks\n");
147 "slab class %3d: chunk size %9u perslab %7u\n",
161 "slab class %3d: chunk size %9u perslab %7u\n",
175 unsigned int prealloc = 0;
184 if (++prealloc > maxslabs)
188 "Error while preallocating slab memory!\n"
189 "If using -L or other prealloc options, max memory must be "
190 "at least %d megabytes.\n",
192 std::cout <<
"Fatal Error: SlabAllocator::slabs_preallocate()" << std::endl;
216 memset(ptr, 0, (
size_t)len);
228 void* new_list = realloc(p->
slab_list, new_size *
sizeof(
void*));
251 for (x = 0; x < p->
perslab; x++) {
void * get_page_from_global_pool(void)
void * slabs_alloc_unsafe(const size_t size)
pthread_mutex_t slabs_lock
void do_slabs_free(void *ptr, const size_t size)
void * memory_allocate(size_t size)
slabclass_t slabclass[MAX_NUMBER_OF_SLAB_CLASSES]
int grow_slab_list(const unsigned int id)
void slabs_free(void *ptr, size_t size)
#define CHUNK_ALIGN_BYTES
void init(const size_t limit, const double factor, const bool prealloc)
unsigned int slabs_clsid(const size_t size)
int do_slabs_newslab(const unsigned int id)
struct settings_t settings
SlabAllocator(const size_t limit, bool opt4hashmap=false)
#define SLAB_GLOBAL_PAGE_POOL
void slabs_free_unsafe(void *ptr, size_t size)
#define MAX_NUMBER_OF_SLAB_CLASSES
void * do_slabs_alloc(const size_t size)
void slabs_preallocate(const unsigned int maxslabs)
void split_slab_page_into_freelist(char *ptr, const unsigned int id)
void * slabs_alloc(const size_t size)