From 7ebfe844892f9f4822046f98f91bfa85b3e39714 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Sat, 28 Jan 2023 22:00:22 +0100 Subject: Fixed some isse with last lib init/fini refactor (fixed ut2004, maybe pokewilds too) --- src/librarian/librarian.c | 4 ++-- src/librarian/library.c | 16 ++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'src/librarian') diff --git a/src/librarian/librarian.c b/src/librarian/librarian.c index 5504e961..919389bc 100755 --- a/src/librarian/librarian.c +++ b/src/librarian/librarian.c @@ -168,7 +168,7 @@ int AddNeededLib_add(lib_t* maplib, int local, needed_libs_t* needed, int n, box // first check if lib is already loaded library_t *lib = getLib(my_context->maplib, path); if(lib) { - IncRefCount(lib); // increment cntref + IncRefCount(lib, emu); // increment cntref needed->libs[n] = lib; printf_log(LOG_DEBUG, "Already present in maplib => success\n"); return 0; @@ -178,7 +178,7 @@ int AddNeededLib_add(lib_t* maplib, int local, needed_libs_t* needed, int n, box if(lib) { printf_log(LOG_DEBUG, "Already present in local_maplib => success\n"); needed->libs[n] = lib; - IncRefCount(lib); // increment cntref + IncRefCount(lib, emu); // increment cntref if(local) { // add lib to maplib... if(maplib) { diff --git a/src/librarian/library.c b/src/librarian/library.c index 1c18c9dc..76fc2898 100755 --- a/src/librarian/library.c +++ b/src/librarian/library.c @@ -1058,13 +1058,17 @@ void setNeededLibs(library_t* lib, int n, ...) va_end (va); } -void IncRefCount(library_t* lib) +void IncRefCount(library_t* lib, x64emu_t* emu) { - if(lib->type!=LIB_WRAPPED && lib->type!=LIB_UNNKNOW) + if(lib->type==LIB_UNNKNOW) return; - if(lib->type==LIB_WRAPPED) { - ++lib->w.refcnt; - } else { - ++lib->e.elf->refcnt; + if(!lib->active) + ReloadLibrary(lib, emu); + switch (lib->type) { + case LIB_WRAPPED: + ++lib->w.refcnt; + break; + case LIB_EMULATED: + ++lib->e.elf->refcnt; } } \ No newline at end of file -- cgit 1.4.1