+2019-12-03 Philippe Waroquiers <philippe.waroquiers@skynet.be>
+ * symtab.c (symbol_cache_clear_slot): Move close to cleared type.
+ (destroy_block_symbol_cache): New function.
+ (symbol_cache:~symbol_cache) Call destroy_block_symbol_cache.
+ (resize_symbol_cache): Likewise.
+
2019-12-02 Tom Tromey <tom@tromey.com>
* unittests/tui-selftests.c (run_tests): Make conditional.
} value;
};
+/* Clear out SLOT. */
+
+static void
+symbol_cache_clear_slot (struct symbol_cache_slot *slot)
+{
+ if (slot->state == SYMBOL_SLOT_NOT_FOUND)
+ xfree (slot->value.not_found.name);
+ slot->state = SYMBOL_SLOT_UNUSED;
+}
+
/* Symbols don't specify global vs static block.
So keep them in separate caches. */
struct symbol_cache_slot symbols[1];
};
+/* Clear all slots of BSC and free BSC. */
+
+static void
+destroy_block_symbol_cache (struct block_symbol_cache *bsc)
+{
+ if (bsc != nullptr)
+ {
+ for (unsigned int i = 0; i < bsc->size; i++)
+ symbol_cache_clear_slot (&bsc->symbols[i]);
+ xfree (bsc);
+ }
+}
+
/* The symbol cache.
Searching for symbols in the static and global blocks over multiple objfiles
~symbol_cache ()
{
- xfree (global_symbols);
- xfree (static_symbols);
+ destroy_block_symbol_cache (global_symbols);
+ destroy_block_symbol_cache (static_symbols);
}
struct block_symbol_cache *global_symbols = nullptr;
&& new_size == 0))
return;
- xfree (cache->global_symbols);
- xfree (cache->static_symbols);
+ destroy_block_symbol_cache (cache->global_symbols);
+ destroy_block_symbol_cache (cache->static_symbols);
if (new_size == 0)
{
return {};
}
-/* Clear out SLOT. */
-
-static void
-symbol_cache_clear_slot (struct symbol_cache_slot *slot)
-{
- if (slot->state == SYMBOL_SLOT_NOT_FOUND)
- xfree (slot->value.not_found.name);
- slot->state = SYMBOL_SLOT_UNUSED;
-}
-
/* Mark SYMBOL as found in SLOT.
OBJFILE_CONTEXT is the current objfile when the lookup was done, or NULL
if it's not needed to distinguish lookups (STATIC_BLOCK). It is *not*