24 using std::cout;
using std::endl;
26 #include "system_constants.hpp" 44 template <
typename TYPE>
66 template <
typename TYPE>
75 = (
goda_block<TYPE> *)malloc(10000 * data_size*
sizeof(TYPE)*
sizeof(long)/
sizeof(TYPE));
77 for (
unsigned i=0; i < 9998; ++i) {
78 tmp->
next = &(tmp[data_size]);
93 big_blocks = block = allocate_new_block();
94 block->next =
nullptr; block += data_size;
98 while (big_blocks !=
nullptr) {
101 big_blocks = next_block;
109 if (block ==
nullptr) {
110 block = allocate_new_block();
111 block->next = big_blocks; big_blocks = block; block += data_size;
113 TYPE * result = (TYPE *)block;
123 new_head->
next = block;
special memory pool allocator for Grevlex_Order_Data and WGrevlex_Order_Data
goda_block< TYPE > * block
pointer to the next free block
TYPE * get_new_block()
allocates and returns a block of memory
goda_block< TYPE > * big_blocks
pointer to the superblock of all blocks
~Grading_Order_Data_Allocator()
releases all memory — you'd better have freed yours!
Grading_Order_Data_Allocator(NVAR_TYPE n)
sets allocator up for blocks of of type TYPE.
TYPE * data
the data contained in this block
void return_used_block(TYPE *freed_block)
returns a block of memory that is no longer needed to the pool
heart of the memory pool allocator (Grading_Order_Data_Allocator)
goda_block< TYPE > * allocate_new_block()
allocates a new superblock of almost 10000 blocks
goda_block * next
pointer to the next free block
const unsigned data_size
how many words to step from one block to the next