* Author:
* Paolo Molaro (lupus@ximian.com)
*
- * (C) 2006 Novell, Inc.
+ * Copyright 2006-2009 Novell, Inc (http://www.novell.com)
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include "mono/metadata/mono-mlist.h"
#include "mono/metadata/appdomain.h"
#include "mono/metadata/class-internals.h"
+#include "mono/metadata/object-internals.h"
-/* matches the System.MonoListItem objcet*/
+/* matches the System.MonoListItem object*/
struct _MonoMList {
MonoObject object;
MonoMList *next;
MonoMList*
mono_mlist_alloc (MonoObject *data)
{
+ MonoError error;
MonoMList* res;
if (!monolist_item_vtable) {
- MonoClass *klass = mono_class_from_name (mono_defaults.corlib, "System", "MonoListItem");
+ MonoClass *klass = mono_class_load_from_name (mono_defaults.corlib, "System", "MonoListItem");
monolist_item_vtable = mono_class_vtable (mono_get_root_domain (), klass);
+ g_assert (monolist_item_vtable);
}
- res = (MonoMList*)mono_object_new_fast (monolist_item_vtable);
+ res = (MonoMList*)mono_object_new_fast_checked (monolist_item_vtable, &error);
+ mono_error_raise_exception (&error);
MONO_OBJECT_SETREF (res, data, data);
return res;
}
MONO_OBJECT_SETREF (list, data, data);
}
+/**
+ * mono_mlist_set_next:
+ * @list: a managed list node
+ * @next: list node that will be next for the @list node.
+ *
+ * Set next node for @list to @next.
+ */
+MonoMList *
+mono_mlist_set_next (MonoMList* list, MonoMList *next)
+{
+ if (!list)
+ return next;
+
+ MONO_OBJECT_SETREF (list, next, next);
+ return list;
+}
+
/**
* mono_mlist_length:
* @list: the managed list
/**
* mono_mlist_remove_item:
* @list: the managed list
- * @data: the object to add to the list
+ * @data: the object to remove from the list
*
* Remove the list node @item from the managed list @list.
* Since managed lists are singly-linked, this operation can take O(n) time.