1 /* ______ ___ ___ 2 * /\ _ \ /\_ \ /\_ \ 3 * \ \ \L\ \\//\ \ \//\ \ __ __ _ __ ___ 4 * \ \ __ \ \ \ \ \ \ \ /'__`\ /'_ `\/\`'__\/ __`\ 5 * \ \ \/\ \ \_\ \_ \_\ \_/\ __//\ \L\ \ \ \//\ \L\ \ 6 * \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/ 7 * \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/ 8 * /\____/ 9 * \_/__/ 10 * 11 * Memory management routines. 12 * 13 * See readme.txt for copyright information. 14 */ 15 16 #ifndef __al_included_allegro5_memory_h 17 #define __al_included_allegro5_memory_h 18 19 #include "allegro5/base.h" 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 26 /* Type: ALLEGRO_MEMORY_INTERFACE 27 */ 28 typedef struct ALLEGRO_MEMORY_INTERFACE ALLEGRO_MEMORY_INTERFACE; 29 30 struct ALLEGRO_MEMORY_INTERFACE { 31 void *(*mi_malloc)(size_t n, int line, const char *file, const char *func); 32 void (*mi_free)(void *ptr, int line, const char *file, const char *func); 33 void *(*mi_realloc)(void *ptr, size_t n, int line, const char *file, const char *func); 34 void *(*mi_calloc)(size_t count, size_t n, int line, const char *file, const char *func); 35 }; 36 37 AL_FUNC(void, al_set_memory_interface, (ALLEGRO_MEMORY_INTERFACE *iface)); 38 39 40 /* Function: al_malloc 41 */ 42 #define al_malloc(n) \ 43 (al_malloc_with_context((n), __LINE__, __FILE__, __func__)) 44 45 /* Function: al_free 46 */ 47 #define al_free(p) \ 48 (al_free_with_context((p), __LINE__, __FILE__, __func__)) 49 50 /* Function: al_realloc 51 */ 52 #define al_realloc(p, n) \ 53 (al_realloc_with_context((p), (n), __LINE__, __FILE__, __func__)) 54 55 /* Function: al_calloc 56 */ 57 #define al_calloc(c, n) \ 58 (al_calloc_with_context((c), (n), __LINE__, __FILE__, __func__)) 59 60 61 AL_FUNC(void *, al_malloc_with_context, (size_t n, 62 int line, const char *file, const char *func)); 63 AL_FUNC(void, al_free_with_context, (void *ptr, 64 int line, const char *file, const char *func)); 65 AL_FUNC(void *, al_realloc_with_context, (void *ptr, size_t n, 66 int line, const char *file, const char *func)); 67 AL_FUNC(void *, al_calloc_with_context, (size_t count, size_t n, 68 int line, const char *file, const char *func)); 69 70 71 #ifdef __cplusplus 72 } 73 #endif 74 75 #endif 76