2003-11-03 17:22:45 +01:00
|
|
|
#ifndef __MEM_H__
|
|
|
|
#define __MEM_H__
|
|
|
|
|
|
|
|
#include "res.h"
|
|
|
|
|
2003-11-12 15:47:38 +01:00
|
|
|
// include memory mappings because the VFS may return either a chunk of
|
|
|
|
// memory, or the mapped file, and a client doesn't know the difference.
|
|
|
|
|
2003-11-03 17:22:45 +01:00
|
|
|
enum MemType
|
|
|
|
{
|
|
|
|
MEM_POOL,
|
2003-11-12 15:47:38 +01:00
|
|
|
MEM_HEAP,
|
|
|
|
MEM_MAPPED
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct MEM
|
|
|
|
{
|
|
|
|
void* p;
|
|
|
|
size_t size;
|
|
|
|
|
|
|
|
MemType type;
|
|
|
|
|
|
|
|
union
|
|
|
|
{
|
|
|
|
size_t ofs; // MEM_POOL only
|
|
|
|
void* org_p; // MEM_HEAP only
|
|
|
|
int fd; // MEM_MAPPED only
|
|
|
|
};
|
2003-11-03 17:22:45 +01:00
|
|
|
};
|
|
|
|
|
2003-11-12 15:47:38 +01:00
|
|
|
extern void* mem_alloc(size_t size, uint align = 1, MemType type = MEM_HEAP, int fd = -1, Handle* ph = 0);
|
2003-11-03 17:22:45 +01:00
|
|
|
extern int mem_free(void* p);
|
|
|
|
|
2003-11-12 15:47:38 +01:00
|
|
|
// faster than mem_free(void*) - no scan of open handles for the pointer
|
|
|
|
extern int mem_free(Handle hm);
|
|
|
|
|
2003-11-03 17:22:45 +01:00
|
|
|
#endif // #ifndef __MEM_H__
|