00001 /* libIntegra multimedia module definition interface 00002 * 00003 * Copyright (C) 2007 Jamie Bullock, Henrik Frisk 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 00018 * USA. 00019 */ 00020 00021 #ifndef INTEGRA_MEMORY_H 00022 #define INTEGRA_MEMORY_H 00023 00024 #include <stdlib.h> 00025 00026 #ifdef __cplusplus 00027 extern "C" { 00028 #endif 00029 00036 enum ntg_allocation_types_ { 00037 NTG_MALLOC, 00038 NTG_CALLOC 00039 }; 00040 00042 typedef struct ntg_memkeeper_ { 00043 00044 struct ntg_memkeeper_ *next; 00045 struct ntg_memkeeper_ *prev; 00046 void *mem; /* address of the allocated memory */ 00047 int index; 00048 size_t bytes; 00049 int reference_count; 00050 00051 } ntg_memkeeper; 00052 00054 struct ntg_allocation_table_ { 00055 00056 ntg_memkeeper *start; 00057 ntg_memkeeper *end; 00058 int allocation_count; 00059 int free_count; 00060 int sweeping; /* Set to 1 if we are sweeping the table */ 00061 00062 }; 00063 00074 void *ntg_calloc(size_t nmemb, size_t size); 00075 00085 void *ntg_malloc(size_t size); 00086 00099 int ntg_free(void *ptr); 00100 00116 void *ntg_realloc(void *ptr, size_t size); 00117 00131 void *ntg_alloc(size_t nmemb, size_t size, int allocation_type); 00132 00134 int ntg_sweep_allocation_table(void); 00135 00142 void *ntg_make_alias(void *ptr); 00143 00151 int ntg_kill_alias(void *ptr); 00152 00160 ntg_memkeeper *ntg_find_memkeeper(void *ptr); 00161 00162 00163 #ifdef __cplusplus 00164 } 00165 #endif 00166 00167 #endif