From 8a01167c7dc5acbbee636c66017f5f35e8766865 Mon Sep 17 00:00:00 2001 From: Itamar Date: Sat, 8 May 2021 12:27:12 +0300 Subject: AK: Add missing GenericTraits This enables us to use keys of type NonnullRefPtr in HashMaps and HashTables. This commit also includes fixes in various places that used HashMap>::get() and expected to get an Optional> and now get an Optional. --- Userland/Libraries/LibELF/DynamicLinker.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'Userland/Libraries/LibELF') diff --git a/Userland/Libraries/LibELF/DynamicLinker.cpp b/Userland/Libraries/LibELF/DynamicLinker.cpp index 3423e517a4..6551d9db55 100644 --- a/Userland/Libraries/LibELF/DynamicLinker.cpp +++ b/Userland/Libraries/LibELF/DynamicLinker.cpp @@ -311,7 +311,7 @@ static Result, DlErrorMessage> load_main_library(co loader.load_stage_4(); } - return main_library_loader; + return NonnullRefPtr(*main_library_loader); } static Result __dlclose(void* handle) @@ -377,7 +377,8 @@ static Result __dlopen(const char* filename, int flags) auto existing_elf_object = s_global_objects.get(library_name); if (existing_elf_object.has_value()) { // It's up to the caller to release the ref with dlclose(). - return &existing_elf_object->leak_ref(); + existing_elf_object.value()->ref(); + return *existing_elf_object; } VERIFY(!library_name.is_empty()); @@ -406,7 +407,8 @@ static Result __dlopen(const char* filename, int flags) return DlErrorMessage { "Could not load ELF object." }; // It's up to the caller to release the ref with dlclose(). - return &object->leak_ref(); + object.value()->ref(); + return *object; } static Result __dlsym(void* handle, const char* symbol_name) -- cgit v1.2.3