netgen/libsrc/general/optmem.hpp

60 lines
1.0 KiB
C++
Raw Normal View History

2009-01-13 04:40:13 +05:00
#ifndef FILE_OPTMEM
#define FILE_OPTMEM
/**************************************************************************/
/* File: optmem.hh */
/* Author: Joachim Schoeberl */
/* Date: 04. Apr. 97 */
/**************************************************************************/
/**
Optimized Memory allocation classes
*/
class BlockAllocator
{
private:
///
unsigned size, blocks;
///
void * freelist;
///
2009-01-25 17:35:25 +05:00
Array<char*> bablocks;
2009-01-13 04:40:13 +05:00
public:
///
BlockAllocator (unsigned asize, unsigned ablocks = 100);
///
~BlockAllocator ();
///
void * Alloc ();
/*
{
if (!freelist)
Alloc2();
void * p = freelist;
// freelist = *(void**)freelist;
freelist = *static_cast<void**> (freelist);
return p;
}
*/
///
void Free (void * p)
{
*(void**)p = freelist;
freelist = p;
}
private:
// void Alloc2 ();
};
#endif