1
0
forked from 0ad/0ad
0ad/source/lib/res/mem.h
janwas 494d27bdd4 moved SAFE_DELETE to lib.h
dyn_array supports "wrapping" other types of memory (stopgap measure)
texture codecs now load via DynArray (intermediate step to all mem stuff
going through res/mem.cpp)
simplified tex codecs by doing as many checks as possible in
tex_load_mem ("template method"-esque)

This was SVN commit r2690.
2005-09-08 01:47:45 +00:00

43 lines
771 B
C
Executable File

#ifndef MEM_H
#define MEM_H
#include "handle.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef void(*MEM_DTOR)(void* p, size_t size, uintptr_t ctx);
// mem_alloc flags
enum
{
// RES_*
MEM_ZERO = 0x1000
};
extern void* mem_alloc(size_t size, size_t align = 1, uint flags = 0, Handle* ph = 0);
#define mem_free(p) mem_free_p((void*&)p)
extern int mem_free_p(void*& p);
extern int mem_free_h(Handle& hm);
// returns 0 if the handle is invalid
extern void* mem_get_ptr(Handle h, size_t* size = 0);
extern int mem_get(Handle hm, u8** pp, size_t* psize);
extern void mem_shutdown(void);
extern Handle mem_assign(void* p, size_t size, uint flags, void* raw_p, size_t raw_size, MEM_DTOR dtor, uintptr_t ctx);
#ifdef __cplusplus
}
#endif
#endif // #ifndef MEM_H