From a6e69bda71440f40d6c9d289258a69c0942b90ba Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 16 Feb 2020 19:36:15 +0100 Subject: AK: Add basic Traits for RefPtr This allows RefPtr to be stored in a HashTable> :^) It's unfortunate about the const_casts. We'll need to fix HashMap::get to play nice with non-const Traits::PeekType at some point. --- Libraries/LibC/dlfcn.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'Libraries/LibC/dlfcn.cpp') diff --git a/Libraries/LibC/dlfcn.cpp b/Libraries/LibC/dlfcn.cpp index c7bea4b50b..9531511525 100644 --- a/Libraries/LibC/dlfcn.cpp +++ b/Libraries/LibC/dlfcn.cpp @@ -74,8 +74,7 @@ void* dlopen(const char* filename, int flags) auto existing_elf_object = g_elf_objects.get(file_path.basename()); if (existing_elf_object.has_value()) { - void* referenced_object = existing_elf_object.value().leak_ref(); - return referenced_object; + return const_cast(existing_elf_object.value()); } int fd = open(filename, O_RDONLY); @@ -110,7 +109,7 @@ void* dlopen(const char* filename, int flags) g_dlerror_msg = "Successfully loaded ELF object."; // we have one refcount already - return g_elf_objects.get(file_path.basename()).value().ptr(); + return const_cast(g_elf_objects.get(file_path.basename()).value()); } void* dlsym(void* handle, const char* symbol_name) -- cgit v1.2.3