+ unlock_handles (handles);
+ /*g_print ("get target of entry %d of type %d: %p\n", slot, handles->type, obj);*/
+ return obj;
+}
+
+static void
+mono_gchandle_set_target (guint32 gchandle, MonoObject *obj)
+{
+ guint slot = gchandle >> 2;
+ HandleData *handles = &gc_handles [gchandle & 3];
+ lock_handles (handles);
+ if (slot < handles->size) {
+#ifdef HAVE_BOEHM_GC
+ if (handles->type <= HANDLE_WEAK_TRACK) {
+ GC_unregister_disappearing_link (&handles->entries [slot]);
+ GC_GENERAL_REGISTER_DISAPPEARING_LINK (&(handles->entries [slot]), obj);
+ handles->entries [slot] = (void*)HIDE_POINTER (obj);
+ } else {
+ handles->entries [slot] = obj;
+ }
+#else
+ handles->entries [slot] = obj;
+#endif
+ } else {
+ /* print a warning? */
+ }
+ /*g_print ("changed entry %d of type %d to object %p (in slot: %p)\n", slot, gchandle & 3, obj, handles->entries [slot]);*/
+ unlock_handles (handles);
+}
+
+void
+mono_gchandle_free (guint32 gchandle)
+{
+ guint slot = gchandle >> 2;
+ HandleData *handles = &gc_handles [gchandle & 3];
+ lock_handles (handles);
+ if (slot < handles->size) {
+#ifdef HAVE_BOEHM_GC
+ if (handles->type <= HANDLE_WEAK_TRACK)
+ GC_unregister_disappearing_link (&handles->entries [slot]);
+#endif
+ handles->entries [slot] = NULL;
+ handles->bitmap [slot / 32] &= ~(1 << (slot % 32));
+ } else {
+ /* print a warning? */
+ }
+ /*g_print ("freed entry %d of type %d\n", slot, gchandle & 3);*/
+ unlock_handles (handles);