Enabled g_mem_set_vtable through the configure option --with-overridable-allocators...
[mono.git] / mono / utils / mono-publib.h
index 30c807043998a61ef995c29c63f3ffe1ac79524d..df810a98e1ae1c8fccf1e93d7168713b2fc04f5c 100644 (file)
@@ -53,6 +53,8 @@ typedef unsigned __int64      uint64_t;
 
 #endif /* end of compiler-specific stuff */
 
+#include <stdlib.h>
+
 #if defined(MONO_DLL_EXPORT)
        #define MONO_API MONO_API_EXPORT
 #elif defined(MONO_DLL_IMPORT)
@@ -69,10 +71,35 @@ typedef uint32_t    mono_unichar4;
 typedef void   (*MonoFunc)     (void* data, void* user_data);
 typedef void   (*MonoHFunc)    (void* key, void* value, void* user_data);
 
+typedef struct {
+       void* (*malloc)  (size_t n_bytes);
+       void* (*realloc) (void* mem, size_t n_bytes);
+       void  (*free)    (void* mem);
+       void* (*calloc)  (size_t n_blocks, size_t n_block_bytes);
+} MonoAllocatorVTable;
+
+/* 
+ * eglib must be built with overridable allocator support (G_OVERRIDABLE_ALLOCATORS=1) 
+ * for mono_set_allocator_vtable to do anything.
+ */
+MONO_API void mono_set_allocator_vtable (MonoAllocatorVTable* vtable);
+
 MONO_API void mono_free (void *);
 
 #define MONO_CONST_RETURN const
 
+/*
+ * When embedding, you have to define MONO_ZERO_LEN_ARRAY before including any
+ * other Mono header file if you use a different compiler from the one used to
+ * build Mono.
+ */
+#ifndef MONO_ZERO_LEN_ARRAY
+#ifdef __GNUC__
+#define MONO_ZERO_LEN_ARRAY 0
+#else
+#define MONO_ZERO_LEN_ARRAY 1
+#endif
+#endif
 
 #if defined (MONO_INSIDE_RUNTIME)