Made xuni more C++-compatible by adding extern "C" to all header files.
[xuni.git] / src / memory.h
blobc9dba8609758c95c82500db8ef9e7b323d530d4c
1 /*! \file memory.h
3 */
5 #ifndef XUNI_GUARD_MEMORY_H
6 #define XUNI_GUARD_MEMORY_H
8 #include "SDL.h"
9 #include "version.h"
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
15 #ifdef VERSION_STDC_C99
16 #define RECORD_FUNCTION_NAMES
17 #endif
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 */
23 MEMORY_BLOCK_TYPES
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__)
52 #else
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")
59 #endif
61 #ifdef __cplusplus
63 #endif
65 #endif