5 #ifndef XUNI_GUARD_MEMORY_H
6 #define XUNI_GUARD_MEMORY_H
15 #ifdef VERSION_STDC_C99
16 #define RECORD_FUNCTION_NAMES
19 enum xuni_memory_block_type_t
{
20 MEMORY_BLOCK_TYPE_NORMAL
,
21 MEMORY_BLOCK_TYPE_SDL_SURFACE
,
22 MEMORY_BLOCK_TYPE_LOADSO_OBJECT
, /* <- unused */
26 size_t allocated_sdl_surface(SDL_Surface
*surface
);
27 void decrement_allocated(size_t size
);
28 void increment_allocated(size_t size
);
30 void xuni_memory_initialize(void);
31 void *xuni_memory_allocate_func(size_t size
, const char *func
);
32 char *xuni_memory_duplicate_string(const char *data
);
33 char *xuni_memory_duplicate_string_len(const char *data
, size_t len
);
34 void *xuni_memory_resize_func(void *data
, size_t size
, const char *func
);
35 void xuni_memory_add_block_func(void *data
, const char *func
,
36 enum xuni_memory_block_type_t type
);
37 void xuni_memory_increment(void *data
);
38 void *xuni_memory_decrement(void *data
);
39 /*void xuni_memory_add_count(void *data, int count);
40 size_t xuni_memory_get_count(void *data);*/
41 void xuni_memory_free(void *data
);
42 void xuni_memory_keep_freed_blocks(int keep
);
43 void xuni_memory_free_all(void);
45 #ifdef RECORD_FUNCTION_NAMES
46 #define xuni_memory_allocate(size) \
47 xuni_memory_allocate_func(size, __func__)
48 #define xuni_memory_add_block(data, type) \
49 xuni_memory_add_block_func(data, __func__, type)
50 #define xuni_memory_resize(data, size) \
51 xuni_memory_resize_func(data, size, __func__)
53 #define xuni_memory_allocate(size) \
54 xuni_memory_allocate_func(size, "unknown")
55 #define xuni_memory_add_block(data, type) \
56 xuni_memory_add_block_func(data, "unknown", type)
57 #define xuni_memory_resize(data, size) \
58 xuni_memory_resize_func(data, size, "unknown")