#pragma warning( disable : 4290 )
#include
#include "MemoryExceptions.h"
namespace ManagedMemory
{
struct MemBlock
{
void *_pointer;
size_t _size;
MemBlock(void *pointer, size_t size):
_pointer(pointer), _size(size)
{}
bool operator< (const MemBlock& b) const
{
return
reinterpret_cast
reinterpret_cast
}
};
/**
Interfaccia per gestore di memoria
*/
class MemoryManager
{
public:
virtual void *alloc(size_t amount) throw(MemoryAllocationException) = 0;
virtual void free(void *p) throw(NotOwnedMemoryException) = 0;
};
class MemoryManagerImpl: public MemoryManager
{
void *_heap;
size_t _heapSize;
std::list
std::list
protected:
void defrag();
public:
MemoryManagerImpl(void *p, size_t heapSize);
virtual ~MemoryManagerImpl(void);
virtual void *alloc(size_t amount) throw(MemoryAllocationException);
virtual void free(void *p) throw(NotOwnedMemoryException, DeallocOnNotAllocatedMemory);
};
};
Nessun commento:
Posta un commento