2010-03-08 06:27:02 +01:00
|
|
|
#ifndef IMEMORYPROVIDER_H_INCLUDED
|
|
|
|
#define IMEMORYPROVIDER_H_INCLUDED
|
|
|
|
|
|
|
|
#include "../include/cAudioDefines.h"
|
2010-03-14 00:09:59 +01:00
|
|
|
#include <cstring>
|
2010-03-08 06:27:02 +01:00
|
|
|
namespace cAudio
|
|
|
|
{
|
|
|
|
//! Interface for a class that allocates and frees memory used by cAudio.
|
|
|
|
class IMemoryProvider
|
|
|
|
{
|
|
|
|
public:
|
2010-03-16 02:11:08 +01:00
|
|
|
//! Allocates memory and returns a pointer to it.
|
|
|
|
/**
|
|
|
|
\param size: Size of the memory chunk to allocate in bytes.
|
|
|
|
\param filename: Filename of the source file that this allocation took place in (in Debug) or NULL otherwise.
|
|
|
|
\param line: Line of the source file where this allocation took place (in Debug) or -1 otherwise.
|
|
|
|
\param function: Function that this allocation took place in (in Debug) or NULL otherwise.
|
|
|
|
\return Pointer to the allocated memory or NULL if allocation failed. */
|
2010-03-08 06:27:02 +01:00
|
|
|
virtual void* Allocate(size_t size, const char* filename, int line, const char* function) = 0;
|
2010-03-16 02:11:08 +01:00
|
|
|
|
|
|
|
//! Frees memory previously allocated.
|
|
|
|
/**
|
|
|
|
\param pointer: Pointer to the memory location to free. */
|
2010-03-08 06:27:02 +01:00
|
|
|
virtual void Free(void* pointer) = 0;
|
2010-03-16 02:11:08 +01:00
|
|
|
|
|
|
|
//! Returns the largest possible single allocation that can be made.
|
2010-03-08 06:27:02 +01:00
|
|
|
virtual size_t getMaxAllocationSize() = 0;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif //! IMEMORYPROVIDER_H_INCLUDED
|