7 #ifndef EXTPREALLOC_HPP_
8 #define EXTPREALLOC_HPP_
26 template<
typename Mem>
46 std::cerr <<
"Error: " << __FILE__ <<
" " << __LINE__ <<
" destroying a live object" <<
"\n";
77 virtual long int ref()
105 std::cerr << __FILE__ <<
":" << __LINE__ <<
" Error requesting more memory than the allocated one" << std::endl;
119 return (
char *)
mem->getPointer() +
l_size;
129 return mem->getPointer();
152 return (((
unsigned char *)
mem->getPointer()) +
a_seq );
162 return (((
unsigned char *)
mem->getPointer()) +
a_seq);
172 return (((
unsigned char *)
mem->getPointer()) + offset);
240 for (
size_t i = 0 ; i < mm.size() ; i++)
bool isInitialized()
Allocated Memory is never initialized.
virtual void deviceToHost()
Do nothing.
long int ref_cnt
Reference counter.
virtual void * getPointer()
Return the pointer of the last allocation.
void shift_forward(size_t sz)
shift the pointer forward
void shift_backward(size_t sz)
shift the pointer backward
size_t a_seq
Actual allocation pointer.
virtual bool allocate(size_t sz)
Allocate a chunk of memory.
ExtPreAlloc()
Default constructor.
virtual long int ref()
Return the reference counter.
size_t l_size
Last allocation size.
ExtPreAlloc(size_t size, Mem &mem)
Preallocated memory sequence.
virtual bool flush()
flush the memory
void * getPointerOffset(size_t offset)
Get the base memory pointer increased with an offset.
virtual void incRef()
Increment the reference counter.
virtual bool copy(const memory &m)
Copy memory.
virtual bool resize(size_t sz)
Allocate or resize the allocated memory.
void * getPointerBase()
The the base pointer of the preallocate memory.
void destroy()
Destroy memory.
virtual void decRef()
Decrement the reference counter.
Mem * mem
Main class for memory allocation.
virtual const void * getPointer() const
Return the pointer of the last allocation.
virtual size_t size() const
Get the size of the LAST allocated memory.
virtual void * getDevicePointer()
Return the pointer of the last allocation.
static size_t calculateMem(std::vector< size_t > &mm)
Calculate the total memory required to pack the message.
void * getPointerEnd()
Return the end pointer of the previous allocated memory.