- if (!(*dlopened = dlopen(ptr, RTLD_LAZY|RTLD_LOCAL))) {
- data->error(data, NULL, PSI_WARNING, "Could not open library '%s': %s.",
- data->psi.file.ln, dlerror());
- return 0;
+ if (!(*dlopened = dlopen(ptr, RTLD_LAZY | RTLD_LOCAL))) {
+ dst->error(dst, NULL, PSI_WARNING, "Could not open library '%s': %s.",
+ src->file.ln, dlerror());
+ return false;
+ }
+
+ if (!dst->libs) {
+ dst->libs = psi_plist_init((psi_plist_dtor) psi_libs_free);
+ }
+ dst->libs = psi_plist_add(dst->libs, dlopened);
+
+ return true;
+}
+
+void psi_libs_free(void **dlopened) {
+ if (*dlopened) {
+ dlclose(*dlopened);