First set of licensing changes
[mono.git] / mono / metadata / profiler.c
index f6a914040832e8ec3b1409baa9399269e8039133..b2620ecf030075854d47d30ca77e767a4958c518 100644 (file)
@@ -8,6 +8,7 @@
  * Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
  * Copyright 2004-2009 Novell, Inc (http://www.novell.com)
  * Copyright 2011 Xamarin Inc (http://www.xamarin.com).
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
  */
 
 #include "config.h"
@@ -159,11 +160,11 @@ void
 mono_profiler_set_events (MonoProfileFlags events)
 {
        ProfilerDesc *prof;
-       MonoProfileFlags value = 0;
+       MonoProfileFlags value = (MonoProfileFlags)0;
        if (prof_list)
                prof_list->events = events;
        for (prof = prof_list; prof; prof = prof->next)
-               value |= prof->events;
+               value = (MonoProfileFlags)(value | prof->events);
        mono_profiler_events = value;
 }
 
@@ -813,7 +814,7 @@ mono_profiler_shutdown (void)
                        prof->shutdown_callback (prof->profiler);
        }
 
-       mono_profiler_set_events (0);
+       mono_profiler_set_events ((MonoProfileFlags)0);
 }
 
 void
@@ -1018,7 +1019,7 @@ mono_profiler_coverage_alloc (MonoMethod *method, int entries)
        if (!coverage_hash)
                coverage_hash = g_hash_table_new (NULL, NULL);
 
-       res = g_malloc0 (sizeof (MonoProfileCoverageInfo) + sizeof (void*) * 2 * entries);
+       res = (MonoProfileCoverageInfo *)g_malloc0 (sizeof (MonoProfileCoverageInfo) + sizeof (void*) * 2 * entries);
 
        res->entries = entries;
 
@@ -1040,7 +1041,7 @@ mono_profiler_coverage_free (MonoMethod *method)
                return;
        }
 
-       info = g_hash_table_lookup (coverage_hash, method);
+       info = (MonoProfileCoverageInfo *)g_hash_table_lookup (coverage_hash, method);
        if (info) {
                g_free (info);
                g_hash_table_remove (coverage_hash, method);
@@ -1063,6 +1064,7 @@ mono_profiler_coverage_free (MonoMethod *method)
 void 
 mono_profiler_coverage_get (MonoProfiler *prof, MonoMethod *method, MonoProfileCoverageFunc func)
 {
+       MonoError error;
        MonoProfileCoverageInfo* info = NULL;
        int i, offset;
        guint32 code_size;
@@ -1073,13 +1075,14 @@ mono_profiler_coverage_get (MonoProfiler *prof, MonoMethod *method, MonoProfileC
 
        mono_profiler_coverage_lock ();
        if (coverage_hash)
-               info = g_hash_table_lookup (coverage_hash, method);
+               info = (MonoProfileCoverageInfo *)g_hash_table_lookup (coverage_hash, method);
        mono_profiler_coverage_unlock ();
 
        if (!info)
                return;
 
-       header = mono_method_get_header (method);
+       header = mono_method_get_header_checked (method, &error);
+       mono_error_assert_ok (&error);
        start = mono_method_header_get_code (header, &code_size, NULL);
        debug_minfo = mono_debug_lookup_method (method);
 
@@ -1240,7 +1243,7 @@ mono_profiler_load (const char *desc)
                gboolean res = FALSE;
 
                if (col != NULL) {
-                       mname = g_memdup (desc, col - desc + 1);
+                       mname = (char *)g_memdup (desc, col - desc + 1);
                        mname [col - desc] = 0;
                } else {
                        mname = g_strdup (desc);