Merge pull request #3199 from lambdageek/dev/proxy-setter
[mono.git] / mono / utils / mono-publib.c
1 #include "config.h"
2 #include <mono/utils/mono-publib.h>
3 #include <glib.h>
4
5 void
6 mono_free (void *ptr)
7 {
8         g_free (ptr);
9 }
10
11
12 /**
13  * mono_set_allocator_vtable
14  *
15  * Make the runtime use the functions in @vtable for allocating memory.
16  * The provided functions must have the same semantics of their libc's equivalents.
17  *
18  * @return TRUE is the vtable was installed. FALSE if the version is incompatible.
19  */
20 mono_bool
21 mono_set_allocator_vtable (MonoAllocatorVTable* vtable)
22 {
23         if (vtable->version != MONO_ALLOCATOR_VTABLE_VERSION)
24                 return FALSE;
25         GMemVTable g_mem_vtable = { vtable->malloc, vtable->realloc, vtable->free, vtable->calloc};
26         g_mem_set_vtable (&g_mem_vtable);
27         return TRUE;
28 }