janwas
d43aa11d36
vfs: now always check filter in VDir (Not only in debug mode) vfs_tree: free VFS nodes to avoid them appearing as "leaks". bugfix in bucket allocator - wasn't coping with exactly filled buckets correctly all Handle users: add to_string method that writes the interesting parts of a resource's user data to string. h_mgr: show this information when a handle is closed ogl_tex: add ogl_tex_find add 2 timer clients mem: now record address of function that allocated memory GameSetup: fix shutdown order Renderer: allow freeing individual alpha map textures (we cache the composite) This was SVN commit r2981.
50 lines
986 B
C
Executable File
50 lines
986 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 Handle mem_wrap(void* p, size_t size, uint flags, void* raw_p, size_t raw_size, MEM_DTOR dtor, uintptr_t ctx, void* owner);
|
|
|
|
// exception to normal resource shutdown: must not be called before
|
|
// h_mgr_shutdown! (this is because h_mgr calls us to free memory, which
|
|
// requires the pointer -> Handle index still be in place)
|
|
extern void mem_shutdown(void);
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif // #ifndef MEM_H
|