mono_image_unlock (image);
}
-#if CHECKED_BUILD
-
-// These are support for the mempool reference tracking feature in checked-build, but live in image.c due to use of static variables of this file.
-
-// Given an image and a pointer, return the mempool owner if it is either this image or one of its imagesets.
-static MonoMemPoolOwner
-check_for_mempool_owner (void *ptr, MonoImage *image)
-{
- if (mono_mempool_contains_addr (image->mempool, ptr))
- {
- MonoMemPoolOwner owner = {image, NULL};
- return owner;
- }
-
- GSList *l;
- for (l = image->image_sets; l; l = l->next) {
- MonoImageSet *set = l->data;
-
- if (mono_mempool_contains_addr (set->mempool, ptr))
- {
- MonoMemPoolOwner owner = {NULL, set};
- return owner;
- }
- }
-
- return mono_mempool_no_owner;
-}
+// This is support for the mempool reference tracking feature in checked-build, but lives in image.c due to use of static variables of this file.
/**
- * mono_find_mempool_owner:
+ * mono_find_image_owner:
*
- * Find the image or imageset, if any, which a given pointer is located in the memory of.
+ * Find the image, if any, which a given pointer is located in the memory of.
*/
-MonoMemPoolOwner
-mono_find_mempool_owner (void *ptr)
+MonoImage *
+mono_find_image_owner (void *ptr)
{
mono_images_lock ();
- MonoMemPoolOwner owner = mono_mempool_no_owner;
- gboolean searching = TRUE;
+ MonoImage *owner = NULL;
// Iterate over both by-path image hashes
const int hash_candidates[] = {IMAGES_HASH_PATH, IMAGES_HASH_PATH_REFONLY};
int hash_idx;
- for (hash_idx = 0; searching && hash_idx < G_N_ELEMENTS (hash_candidates); hash_idx++)
+ for (hash_idx = 0; !owner && hash_idx < G_N_ELEMENTS (hash_candidates); hash_idx++)
{
GHashTable *target = loaded_images_hashes [hash_candidates [hash_idx]];
GHashTableIter iter;
// Iterate over images within a hash
g_hash_table_iter_init (&iter, target);
- while (searching && g_hash_table_iter_next(&iter, NULL, (gpointer *)&image))
+ while (!owner && g_hash_table_iter_next(&iter, NULL, (gpointer *)&image))
{
mono_image_lock (image);
- owner = check_for_mempool_owner (ptr, image);
+ if (mono_mempool_contains_addr (image->mempool, ptr))
+ owner = image;
mono_image_unlock (image);
-
- // Continue searching if null owner returned
- searching = check_mempool_owner_eq (owner, mono_mempool_no_owner);
}
}
return owner;
}
-
-#endif