From: Eric Pouech epouech@codeweavers.com
Enumeration only report types with name, so we can get rid of module's vtype vector and only the use the types' hash table.
Signed-off-by: Eric Pouech epouech@codeweavers.com --- dlls/dbghelp/dbghelp_private.h | 1 - dlls/dbghelp/module.c | 2 -- dlls/dbghelp/type.c | 45 ++++++++++++---------------------- 3 files changed, 16 insertions(+), 32 deletions(-)
diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h index 63b2b8862de..27f869de4c6 100644 --- a/dlls/dbghelp/dbghelp_private.h +++ b/dlls/dbghelp/dbghelp_private.h @@ -470,7 +470,6 @@ struct module
/* types */ struct hash_table ht_types; - struct vector vtypes;
/* source files */ unsigned sources_used; diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c index 80236d39ee3..ce49ef2744a 100644 --- a/dlls/dbghelp/module.c +++ b/dlls/dbghelp/module.c @@ -204,7 +204,6 @@ struct module* module_new(struct process* pcs, const WCHAR* name, */ hash_table_init(&module->pool, &module->ht_symbols, 4096); hash_table_init(&module->pool, &module->ht_types, 4096); - vector_init(&module->vtypes, sizeof(struct symt*), 0);
module->sources_used = 0; module->sources_alloc = 0; @@ -1566,7 +1565,6 @@ void module_reset_debug_info(struct module* module) hash_table_destroy(&module->ht_types); module->ht_types.num_buckets = 0; module->ht_types.buckets = NULL; - module->vtypes.num_elts = 0; hash_table_destroy(&module->ht_symbols); module->sources_used = module->sources_alloc = 0; module->sources = NULL; diff --git a/dlls/dbghelp/type.c b/dlls/dbghelp/type.c index 9c85a7a613a..7e9bb44e690 100644 --- a/dlls/dbghelp/type.c +++ b/dlls/dbghelp/type.c @@ -213,14 +213,6 @@ static struct symt* symt_find_type_by_name(const struct module* module, return NULL; }
-static void symt_add_type(struct module* module, struct symt* symt) -{ - struct symt** p; - p = vector_add(&module->vtypes, &module->pool); - assert(p); - *p = symt; -} - struct symt_basic* symt_get_basic(enum BasicType bt, unsigned size) { static struct symt_basic cache[32] = { { {SymTagBaseType}, btNoType, 0 } }; @@ -261,7 +253,6 @@ struct symt_udt* symt_new_udt(struct module* module, const char* typename, hash_table_add(&module->ht_types, &sym->hash_elt); } else sym->hash_elt.name = NULL; vector_init(&sym->vchildren, sizeof(struct symt*), 0); - symt_add_type(module, &sym->symt); } return sym; } @@ -346,7 +337,6 @@ struct symt_enum* symt_new_enum(struct module* module, const char* typename, } else sym->hash_elt.name = NULL; sym->base_type = basetype; vector_init(&sym->vchildren, sizeof(struct symt*), 0); - symt_add_type(module, &sym->symt); } return sym; } @@ -389,7 +379,6 @@ struct symt_array* symt_new_array(struct module* module, int min, DWORD cnt, sym->count = cnt; sym->base_type = base; sym->index_type = index; - symt_add_type(module, &sym->symt); } return sym; } @@ -406,7 +395,6 @@ struct symt_function_signature* symt_new_function_signature(struct module* modul sym->rettype = ret_type; vector_init(&sym->vchildren, sizeof(struct symt*), 0); sym->call_conv = call_conv; - symt_add_type(module, &sym->symt); } return sym; } @@ -439,13 +427,12 @@ struct symt_pointer* symt_new_pointer(struct module* module, struct symt* ref_ty sym->symt.tag = SymTagPointerType; sym->pointsto = ref_type; sym->size = size; - symt_add_type(module, &sym->symt); } return sym; }
-struct symt_typedef* symt_new_typedef(struct module* module, struct symt* ref, - const char* name) +struct symt_typedef* symt_new_typedef(struct module* module, struct symt* ref, + const char* typename) { struct symt_typedef* sym;
@@ -453,9 +440,8 @@ struct symt_typedef* symt_new_typedef(struct module* module, struct symt* ref, { sym->symt.tag = SymTagTypedef; sym->type = ref; - sym->hash_elt.name = pool_strdup(&module->pool, name); + sym->hash_elt.name = pool_strdup(&module->pool, typename); hash_table_add(&module->ht_types, &sym->hash_elt); - symt_add_type(module, &sym->symt); } return sym; } @@ -463,24 +449,25 @@ struct symt_typedef* symt_new_typedef(struct module* module, struct symt* ref, static BOOL sym_enum_types(struct module_pair *pair, const char *type_name, PSYM_ENUMERATESYMBOLS_CALLBACK cb, void *user) { char buffer[sizeof(SYMBOL_INFO) + 256]; - struct symt *type; SYMBOL_INFO *sym_info = (SYMBOL_INFO*)buffer; + struct hash_table_iter hti; + void* ptr; + struct symt_ht *type; DWORD64 size; - unsigned int i; - const char *tname;
sym_info->SizeOfStruct = sizeof(SYMBOL_INFO); sym_info->MaxNameLen = sizeof(buffer) - sizeof(SYMBOL_INFO);
- for (i = 0; i < vector_length(&pair->effective->vtypes); i++) + hash_table_iter_init(&pair->effective->ht_types, &hti, type_name); + while ((ptr = hash_table_iter_up(&hti))) { - type = *(struct symt**)vector_at(&pair->effective->vtypes, i); - tname = symt_get_name(type); - if (!tname || !*tname) continue; - if (type_name && !SymMatchStringA(tname, type_name, TRUE)) continue; - sym_info->TypeIndex = symt_ptr2index(pair->effective, type); + type = CONTAINING_RECORD(ptr, struct symt_ht, hash_elt); + + if (type_name && !SymMatchStringA(type->hash_elt.name, type_name, TRUE)) continue; + + sym_info->TypeIndex = symt_ptr2index(pair->effective, &type->symt); sym_info->Index = 0; /* FIXME */ - symt_get_info(pair->effective, type, TI_GET_LENGTH, &size); + symt_get_info(pair->effective, &type->symt, TI_GET_LENGTH, &size); sym_info->Size = size; sym_info->ModBase = pair->requested->module.BaseOfImage; sym_info->Flags = 0; /* FIXME */ @@ -488,8 +475,8 @@ static BOOL sym_enum_types(struct module_pair *pair, const char *type_name, PSYM sym_info->Address = 0; /* FIXME */ sym_info->Register = 0; /* FIXME */ sym_info->Scope = 0; /* FIXME */ - sym_info->Tag = type->tag; - symbol_setname(sym_info, symt_get_name(type)); + sym_info->Tag = type->symt.tag; + symbol_setname(sym_info, type->hash_elt.name); if (!cb(sym_info, sym_info->Size, user)) return FALSE; } return TRUE;