2009-08-18 Rodrigo Kumpera <rkumpera@novell.com>
authorRodrigo Kumpera <kumpera@gmail.com>
Tue, 18 Aug 2009 23:14:11 +0000 (23:14 -0000)
committerRodrigo Kumpera <kumpera@gmail.com>
Tue, 18 Aug 2009 23:14:11 +0000 (23:14 -0000)
* class.c: Fix usage of mono_metadata_interfaces_from_typedef_full.

* metadata-internals.h: Fix declaration of
mono_metadata_interfaces_from_typedef_full.

* metadata.c (mono_metadata_interfaces_from_typedef_full): Add extra
heap_alloc_result parameter that controls if the result should be
g_malloc'd.

* metadata.c (mono_metadata_interfaces_from_typedef): Let the resulting
array be g_malloc'd and properly document this public API function.

svn path=/trunk/mono/; revision=140209

mono/metadata/ChangeLog
mono/metadata/class.c
mono/metadata/metadata-internals.h
mono/metadata/metadata.c

index 5b475b877f88988ab4d7750c10e4ee03c3039811..64caab0419825466a7bfb70b2143a1285f527205 100644 (file)
@@ -1,3 +1,17 @@
+2009-08-18  Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * class.c: Fix usage of mono_metadata_interfaces_from_typedef_full.
+
+       * metadata-internals.h: Fix declaration of 
+       mono_metadata_interfaces_from_typedef_full.
+
+       * metadata.c (mono_metadata_interfaces_from_typedef_full): Add extra
+       heap_alloc_result parameter that controls if the result should be
+       g_malloc'd.
+
+       * metadata.c (mono_metadata_interfaces_from_typedef): Let the resulting
+       array be g_malloc'd and properly document this public API function.
+
 2009-08-18  Rodrigo Kumpera  <rkumpera@novell.com>
 
        * cil-coff.h: Fix METHOD_HEADER_FORMAT_MASK to be 2 bits and
index 9272167192e98c6405bf2b614143a5cc9f025675..3f36ef2a0de869b1cb0d81b2a1772bd0cfef82e1 100644 (file)
@@ -4323,7 +4323,7 @@ mono_class_create_from_typedef (MonoImage *image, guint32 type_token)
 
        if (!class->enumtype) {
                if (!mono_metadata_interfaces_from_typedef_full (
-                           image, type_token, &interfaces, &icount, context)){
+                           image, type_token, &interfaces, &icount, FALSE, context)){
                        mono_loader_unlock ();
                        mono_profiler_class_loaded (class, MONO_PROFILE_FAILED);
                        return NULL;
index 58ae36c460b46c4a71ba16d8080cf16df91a3827..4213ce3aa53ce3477a177a9041724f92b4da1aef 100644 (file)
@@ -431,6 +431,7 @@ mono_metadata_interfaces_from_typedef_full  (MonoImage             *image,
                                                                                         guint32                table_index,
                                                                                         MonoClass           ***interfaces,
                                                                                         guint                 *count,
+                                                                                        gboolean               heap_alloc_result,
                                                                                         MonoGenericContext    *context) MONO_INTERNAL;
 
 MonoArrayType *
index b67236ff3c6f95c0201f19da2f6922f8721093d8..1927bcbc226de47d2c45495807e23e16019e2e07 100644 (file)
@@ -3418,16 +3418,20 @@ mono_metadata_typedef_from_method (MonoImage *meta, guint32 index)
  * mono_metadata_interfaces_from_typedef_full:
  * @meta: metadata context
  * @index: typedef token
+ * @interfaces: Out parameter used to store the interface array
+ * @count: Out parameter used to store the number of interfaces
+ * @heap_alloc_result: if TRUE the result array will be g_malloc'd
+ * @context: The generic context
  * 
  * The array of interfaces that the @index typedef token implements is returned in
- * @interfaces. The number of elemnts in the array is returned in @count.
+ * @interfaces. The number of elements in the array is returned in @count. 
  *
  * LOCKING: Assumes the loader lock is held.
  *
  * Returns: TRUE on success, FALSE on failure.
  */
 gboolean
-mono_metadata_interfaces_from_typedef_full (MonoImage *meta, guint32 index, MonoClass ***interfaces, guint *count, MonoGenericContext *context)
+mono_metadata_interfaces_from_typedef_full (MonoImage *meta, guint32 index, MonoClass ***interfaces, guint *count, gboolean heap_alloc_result, MonoGenericContext *context)
 {
        MonoTableInfo *tdef = &meta->tables [MONO_TABLE_INTERFACEIMPL];
        locator_t loc;
@@ -3466,7 +3470,10 @@ mono_metadata_interfaces_from_typedef_full (MonoImage *meta, guint32 index, Mono
                ++pos;
        }
 
-       result = mono_image_alloc0 (meta, sizeof (MonoClass*) * (pos - start));
+       if (heap_alloc_result)
+               result = g_new0 (MonoClass*, pos - start);
+       else
+               result = mono_image_alloc0 (meta, sizeof (MonoClass*) * (pos - start));
 
        pos = start;
        while (pos < tdef->rows) {
@@ -3487,6 +3494,20 @@ mono_metadata_interfaces_from_typedef_full (MonoImage *meta, guint32 index, Mono
        return TRUE;
 }
 
+/*
+ * @meta: metadata context
+ * @index: typedef token
+ * @count: Out parameter used to store the number of interfaces
+ * 
+ * The array of interfaces that the @index typedef token implements is returned in
+ * @interfaces. The number of elements in the array is returned in @count. The returned
+ * array is g_malloc'd and the caller must free it.
+ *
+ * LOCKING: Acquires the loader lock .
+ *
+ * Returns: the interface array on success, NULL on failure.
+ */
+
 MonoClass**
 mono_metadata_interfaces_from_typedef (MonoImage *meta, guint32 index, guint *count)
 {
@@ -3494,7 +3515,7 @@ mono_metadata_interfaces_from_typedef (MonoImage *meta, guint32 index, guint *co
        gboolean rv;
 
        mono_loader_lock ();
-       rv = mono_metadata_interfaces_from_typedef_full (meta, index, &interfaces, count, NULL);
+       rv = mono_metadata_interfaces_from_typedef_full (meta, index, &interfaces, count, TRUE, NULL);
        mono_loader_unlock ();
        if (rv)
                return interfaces;