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;
|
|
|
|
///
|
2019-07-09 13:39:16 +05:00
|
|
|
NgArray<char*> bablocks;
|
2019-07-09 03:23:09 +05:00
|
|
|
mutex block_allocator_mutex;
|
2009-01-13 04:40:13 +05:00
|
|
|
public:
|
|
|
|
///
|
2020-03-03 16:10:09 +05:00
|
|
|
DLL_HEADER BlockAllocator (unsigned asize, unsigned ablocks = 100);
|
2009-01-13 04:40:13 +05:00
|
|
|
///
|
2020-03-03 16:10:09 +05:00
|
|
|
DLL_HEADER ~BlockAllocator ();
|
2009-01-13 04:40:13 +05:00
|
|
|
///
|
2020-03-03 16:10:09 +05:00
|
|
|
DLL_HEADER void * Alloc ();
|
2009-01-13 04:40:13 +05:00
|
|
|
///
|
2020-03-03 16:10:09 +05:00
|
|
|
DLL_HEADER void Free (void * p);
|
2009-01-13 04:40:13 +05:00
|
|
|
};
|
|
|
|
|
2009-07-20 14:36:36 +06:00
|
|
|
}
|
2009-01-13 04:40:13 +05:00
|
|
|
|
|
|
|
#endif
|