From 71609f7e46e9e47fa60651b531cf1b82bfef64a0 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Mon, 19 Apr 2010 17:27:03 +0000 Subject: [PATCH] applied a hint given from Ingo during BeGeistert: * use dlopen() instead of load_add_on() when loading liblocale.so from libbe.so, as otherwise the library could end up in the image more than once. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36357 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/LocaleBackend.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/kits/LocaleBackend.cpp b/src/kits/LocaleBackend.cpp index 30e0430b9b..7fda14a5f6 100644 --- a/src/kits/LocaleBackend.cpp +++ b/src/kits/LocaleBackend.cpp @@ -6,6 +6,7 @@ #include "LocaleBackend.h" +#include #include #include #include @@ -25,13 +26,14 @@ static pthread_once_t sBackendInitOnce = PTHREAD_ONCE_INIT; static void LoadBackend() { - image_id libLocaleAddonID = load_add_on("/system/lib/liblocale.so"); - - if (libLocaleAddonID < 0) + void* imageHandle = dlopen("liblocale.so", RTLD_LAZY); + if (imageHandle == NULL) return; - LocaleBackend* (*createInstanceFunc)(); - if (get_image_symbol(libLocaleAddonID, "CreateLocaleBackendInstance", - B_SYMBOL_TYPE_TEXT, (void**)&createInstanceFunc) != B_OK) + + typedef LocaleBackend* (*symbolType)(); + symbolType createInstanceFunc = (symbolType)dlsym(imageHandle, + "CreateLocaleBackendInstance"); + if (createInstanceFunc == NULL) return; gLocaleBackend = createInstanceFunc();