diff options
author | Dolphin Hawkins <dolphin@exitzer0.com> | 2016-06-22 19:49:12 +0300 |
---|---|---|
committer | Rodrigo Kumpera <kumpera@gmail.com> | 2016-07-11 20:23:20 +0300 |
commit | 6474f8e6126933773a64374c6a38d662bf80d150 (patch) | |
tree | a96aaccb30f39794f6da2c8b2c9fb5d818af9833 /samples | |
parent | c516dda69361557004044b2c966a11082177033b (diff) |
Enabled g_mem_set_vtable through the configure option --with-overridable-allocators and exposed through mono_set_allocator_vtable
Diffstat (limited to 'samples')
-rw-r--r-- | samples/embed/teste.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/samples/embed/teste.c b/samples/embed/teste.c index 2183ccbb50b..6f727a00e1b 100644 --- a/samples/embed/teste.c +++ b/samples/embed/teste.c @@ -1,5 +1,6 @@ #include <mono/jit/jit.h> #include <mono/metadata/environment.h> +#include <mono/utils/mono-publib.h> #include <stdlib.h> /* @@ -31,6 +32,13 @@ static void main_function (MonoDomain *domain, const char *file, int argc, char* mono_jit_exec (domain, assembly, argc, argv); } +static int malloc_count = 0; + +static void* custom_malloc(size_t bytes) +{ + ++malloc_count; + return malloc(bytes); +} int main(int argc, char* argv[]) { @@ -44,6 +52,9 @@ main(int argc, char* argv[]) { } file = argv [1]; + MonoAllocatorVTable mem_vtable = {custom_malloc}; + mono_set_allocator_vtable (&mem_vtable); + /* * Load the default Mono configuration file, this is needed * if you are planning on using the dllmaps defined on the @@ -66,6 +77,9 @@ main(int argc, char* argv[]) { retval = mono_environment_exitcode_get (); mono_jit_cleanup (domain); + + fprintf (stdout, "custom malloc calls = %d\n", malloc_count); + return retval; } |