Blender  V2.59
MEM_guardedalloc.h
Go to the documentation of this file.
00001 /*
00002  * $Id: MEM_guardedalloc.h 35417 2011-03-09 01:25:59Z campbellbarton $
00003  * ***** BEGIN GPL LICENSE BLOCK *****
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (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 Foundation,
00017  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018  *
00019  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00020  * All rights reserved.
00021  *
00022  * The Original Code is: all of this file.
00023  *
00024  * Contributor(s): none yet.
00025  *
00026  * ***** END GPL LICENSE BLOCK *****
00027  */
00028 
00061 #ifndef MEM_MALLOCN_H
00062 #define MEM_MALLOCN_H
00063 
00064 #include <stdio.h> /* needed for FILE* */
00065 #include "MEM_sys_types.h" /* needed for uintptr_t */
00066 
00067 #ifndef WARN_UNUSED
00068 #  ifdef __GNUC__
00069 #    define WARN_UNUSED  __attribute__((warn_unused_result))
00070 #  else
00071 #    define WARN_UNUSED
00072 #  endif
00073 #endif
00074 
00075 #ifdef __cplusplus
00076 extern "C" {
00077 #endif
00078 
00082         size_t MEM_allocN_len(void *vmemh) WARN_UNUSED;
00083 
00087         short MEM_freeN(void *vmemh);
00088 
00089 
00093         short MEM_testN(void *vmemh);
00094 
00098         void *MEM_dupallocN(void *vmemh) WARN_UNUSED;
00099 
00105         void *MEM_reallocN(void *vmemh, size_t len) WARN_UNUSED;
00106 
00111         void *MEM_callocN(size_t len, const char * str) WARN_UNUSED;
00112         
00116         void *MEM_mallocN(size_t len, const char * str) WARN_UNUSED;
00117         
00121         void *MEM_mapallocN(size_t len, const char * str) WARN_UNUSED;
00122 
00125         void MEM_printmemlist_pydict(void);
00126 
00129         void MEM_printmemlist(void);
00130 
00132         void MEM_callbackmemlist(void (*func)(void*));
00133 
00135         void MEM_printmemlist_stats(void);
00136         
00138         void MEM_set_error_callback(void (*func)(const char *));
00139 
00144         int MEM_check_memory_integrity(void);
00145 
00148         void MEM_set_lock_callback(void (*lock)(void), void (*unlock)(void));
00149         
00151         void MEM_set_memory_debug(void);
00152 
00156         uintptr_t MEM_get_memory_in_use(void);
00158         uintptr_t MEM_get_mapped_memory_in_use(void);
00160         int MEM_get_memory_blocks_in_use(void);
00161 
00163         void MEM_reset_peak_memory(void);
00164 
00166         uintptr_t MEM_get_peak_memory(void) WARN_UNUSED;
00167 
00168 #ifndef NDEBUG
00169 const char *MEM_name_ptr(void *vmemh);
00170 #endif
00171         
00172 #ifdef __cplusplus
00173 }
00174 #endif
00175 
00176 #endif
00177