2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19 * All rights reserved.
21 * The Original Code is: all of this file.
23 * Contributor(s): Brecht Van Lommel
26 * ***** END GPL LICENSE BLOCK *****
29 /** \file guardedalloc/intern/mallocn.c
32 * Guarded memory allocation, and boundary-write detection.
35 #include "MEM_guardedalloc.h"
37 /* to ensure strict conversions */
38 #include "../../source/blender/blenlib/BLI_strict_flags.h"
40 #include "mallocn_intern.h"
42 size_t (*MEM_allocN_len)(const void *vmemh) = MEM_lockfree_allocN_len;
43 void (*MEM_freeN)(void *vmemh) = MEM_lockfree_freeN;
44 void *(*MEM_dupallocN)(const void *vmemh) = MEM_lockfree_dupallocN;
45 void *(*MEM_reallocN_id)(void *vmemh, size_t len, const char *str) = MEM_lockfree_reallocN_id;
46 void *(*MEM_recallocN_id)(void *vmemh, size_t len, const char *str) = MEM_lockfree_recallocN_id;;
47 void *(*MEM_callocN)(size_t len, const char *str) = MEM_lockfree_callocN;
48 void *(*MEM_mallocN)(size_t len, const char *str) = MEM_lockfree_mallocN;
49 void *(*MEM_mapallocN)(size_t len, const char *str) = MEM_lockfree_mapallocN;
50 void (*MEM_printmemlist_pydict)(void) = MEM_lockfree_printmemlist_pydict;
51 void (*MEM_printmemlist)(void) = MEM_lockfree_printmemlist;
52 void (*MEM_callbackmemlist)(void (*func)(void *)) = MEM_lockfree_callbackmemlist;
53 void (*MEM_printmemlist_stats)(void) = MEM_lockfree_printmemlist_stats;
54 void (*MEM_set_error_callback)(void (*func)(const char *)) = MEM_lockfree_set_error_callback;
55 bool (*MEM_check_memory_integrity)(void) = MEM_lockfree_check_memory_integrity;
56 void (*MEM_set_lock_callback)(void (*lock)(void), void (*unlock)(void)) = MEM_lockfree_set_lock_callback;
57 void (*MEM_set_memory_debug)(void) = MEM_lockfree_set_memory_debug;
58 uintptr_t (*MEM_get_memory_in_use)(void) = MEM_lockfree_get_memory_in_use;
59 uintptr_t (*MEM_get_mapped_memory_in_use)(void) = MEM_lockfree_get_mapped_memory_in_use;
60 unsigned int (*MEM_get_memory_blocks_in_use)(void) = MEM_lockfree_get_memory_blocks_in_use;
61 void (*MEM_reset_peak_memory)(void) = MEM_lockfree_reset_peak_memory;
62 uintptr_t (*MEM_get_peak_memory)(void) = MEM_lockfree_get_peak_memory;
65 const char *(*MEM_name_ptr)(void *vmemh) = MEM_lockfree_name_ptr;
68 void MEM_use_guarded_allocator(void)
70 MEM_allocN_len = MEM_guarded_allocN_len;
71 MEM_freeN = MEM_guarded_freeN;
72 MEM_dupallocN = MEM_guarded_dupallocN;
73 MEM_reallocN_id = MEM_guarded_reallocN_id;
74 MEM_recallocN_id = MEM_guarded_recallocN_id;;
75 MEM_callocN = MEM_guarded_callocN;
76 MEM_mallocN = MEM_guarded_mallocN;
77 MEM_mapallocN = MEM_guarded_mapallocN;
78 MEM_printmemlist_pydict = MEM_guarded_printmemlist_pydict;
79 MEM_printmemlist = MEM_guarded_printmemlist;
80 MEM_callbackmemlist = MEM_guarded_callbackmemlist;
81 MEM_printmemlist_stats = MEM_guarded_printmemlist_stats;
82 MEM_set_error_callback = MEM_guarded_set_error_callback;
83 MEM_check_memory_integrity = MEM_guarded_check_memory_integrity;
84 MEM_set_lock_callback = MEM_guarded_set_lock_callback;
85 MEM_set_memory_debug = MEM_guarded_set_memory_debug;
86 MEM_get_memory_in_use = MEM_guarded_get_memory_in_use;
87 MEM_get_mapped_memory_in_use = MEM_guarded_get_mapped_memory_in_use;
88 MEM_get_memory_blocks_in_use = MEM_guarded_get_memory_blocks_in_use;
89 MEM_reset_peak_memory = MEM_guarded_reset_peak_memory;
90 MEM_get_peak_memory = MEM_guarded_get_peak_memory;
93 MEM_name_ptr = MEM_guarded_name_ptr;