sgen_hash_table_replace can now return the old value.
authorRodrigo Kumpera <kumpera@gmail.com>
Mon, 21 May 2012 21:26:27 +0000 (18:26 -0300)
committerRodrigo Kumpera <kumpera@gmail.com>
Tue, 22 May 2012 15:58:17 +0000 (12:58 -0300)
mono/metadata/sgen-gc.h
mono/metadata/sgen-hash-table.c
mono/metadata/sgen-pinning-stats.c

index 89ccdda067cc32b85239dcb8dc37330f699263eb..31a83d53101d3782150a77860c25006dc510f4e0 100644 (file)
@@ -871,7 +871,7 @@ typedef struct {
 #define SGEN_HASH_TABLE_ENTRY_SIZE(data_size)                  ((data_size) + sizeof (SgenHashTableEntry*) + sizeof (gpointer))
 
 gpointer sgen_hash_table_lookup (SgenHashTable *table, gpointer key) MONO_INTERNAL;
-gboolean sgen_hash_table_replace (SgenHashTable *table, gpointer key, gpointer data) MONO_INTERNAL;
+gboolean sgen_hash_table_replace (SgenHashTable *table, gpointer key, gpointer new_value, gpointer old_value) MONO_INTERNAL;
 gboolean sgen_hash_table_set_value (SgenHashTable *table, gpointer key, gpointer new_value, gpointer old_value) MONO_INTERNAL;
 gboolean sgen_hash_table_set_key (SgenHashTable *hash_table, gpointer old_key, gpointer new_key) MONO_INTERNAL;
 gboolean sgen_hash_table_remove (SgenHashTable *table, gpointer key, gpointer data_return) MONO_INTERNAL;
index 740fb26e652f735665e7c7c5cfb91784d6af58f8..af829a2f262c491c9ca239fe527ddeee657484aa 100644 (file)
@@ -96,7 +96,7 @@ sgen_hash_table_lookup (SgenHashTable *hash_table, gpointer key)
 }
 
 gboolean
-sgen_hash_table_replace (SgenHashTable *hash_table, gpointer key, gpointer data)
+sgen_hash_table_replace (SgenHashTable *hash_table, gpointer key, gpointer new_value, gpointer old_value)
 {
        guint hash;
        SgenHashTableEntry *entry;
@@ -105,13 +105,15 @@ sgen_hash_table_replace (SgenHashTable *hash_table, gpointer key, gpointer data)
        entry = lookup (hash_table, key, &hash);
 
        if (entry) {
-               memcpy (entry->data, data, hash_table->data_size);
+               if (old_value)
+                       memcpy (old_value, entry->data, hash_table->data_size); 
+               memcpy (entry->data, new_value, hash_table->data_size);
                return FALSE;
        }
 
        entry = sgen_alloc_internal (hash_table->entry_mem_type);
        entry->key = key;
-       memcpy (entry->data, data, hash_table->data_size);
+       memcpy (entry->data, new_value, hash_table->data_size);
 
        entry->next = hash_table->table [hash];
        hash_table->table [hash] = entry;
index c3c13f5689a652d1f3ccd6f511cd9532043ef087..6b798f2ce6b2658f88ff382b8694af335f146eff 100644 (file)
@@ -136,7 +136,7 @@ lookup_class_entry (SgenHashTable *hash_table, MonoClass *class, gpointer empty_
        if (entry) {
                g_free (name);
        } else {
-               sgen_hash_table_replace (hash_table, name, empty_entry);
+               sgen_hash_table_replace (hash_table, name, empty_entry, NULL);
                entry = sgen_hash_table_lookup (hash_table, name);
        }