forked from Imagelibrary/binutils-gdb
Rewrite registry.h
This rewrites registry.h, removing all the macros and replacing it with relatively ordinary template classes. The result is less code than the previous setup. It replaces large macros with a relatively straightforward C++ class, and now manages its own cleanup. The existing type-safe "key" class is replaced with the equivalent template class. This approach ended up requiring relatively few changes to the users of the registry code in gdb -- code using the key system just required a small change to the key's declaration. All existing users of the old C-like API are now converted to use the type-safe API. This mostly involved changing explicit deletion functions to be an operator() in a deleter class. The old "save/free" two-phase process is removed, and replaced with a single "free" phase. No existing code used both phases. The old "free" callbacks took a parameter for the enclosing container object. However, this wasn't truly needed and is removed here as well.
This commit is contained in:
@@ -87,7 +87,7 @@
|
||||
#include "ctf.h"
|
||||
#include "ctf-api.h"
|
||||
|
||||
static const struct objfile_key<htab, htab_deleter> ctf_tid_key;
|
||||
static const registry<objfile>::key<htab, htab_deleter> ctf_tid_key;
|
||||
|
||||
struct ctf_fp_info
|
||||
{
|
||||
@@ -107,7 +107,7 @@ ctf_fp_info::~ctf_fp_info ()
|
||||
ctf_close (arc);
|
||||
}
|
||||
|
||||
static const objfile_key<ctf_fp_info> ctf_dict_key;
|
||||
static const registry<objfile>::key<ctf_fp_info> ctf_dict_key;
|
||||
|
||||
/* A CTF context consists of a file pointer and an objfile pointer. */
|
||||
|
||||
@@ -243,7 +243,7 @@ set_tid_type (struct objfile *of, ctf_id_t tid, struct type *typ)
|
||||
{
|
||||
htab_t htab;
|
||||
|
||||
htab = (htab_t) ctf_tid_key.get (of);
|
||||
htab = ctf_tid_key.get (of);
|
||||
if (htab == NULL)
|
||||
{
|
||||
htab = htab_create_alloc (1, tid_and_type_hash,
|
||||
@@ -271,7 +271,7 @@ get_tid_type (struct objfile *of, ctf_id_t tid)
|
||||
struct ctf_tid_and_type *slot, ids;
|
||||
htab_t htab;
|
||||
|
||||
htab = (htab_t) ctf_tid_key.get (of);
|
||||
htab = ctf_tid_key.get (of);
|
||||
if (htab == NULL)
|
||||
return nullptr;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user