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
This commit is contained in:
Oliver Tappe 2010-04-19 17:27:03 +00:00
parent 1276d52122
commit 71609f7e46

View File

@ -6,6 +6,7 @@
#include "LocaleBackend.h"
#include <dlfcn.h>
#include <pthread.h>
#include <stdio.h>
#include <string.h>
@ -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();