+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
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;
* 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;
++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) {
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)
{
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;