netgen/libsrc/general/optmem.hpp

63 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 */
/**************************************************************************/
2009-07-20 14:36:36 +06:00
namespace netgen
{
2009-01-13 04:40:13 +05:00
/**
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 ();
};
2009-07-20 14:36:36 +06:00
}
2009-01-13 04:40:13 +05:00
#endif