You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2023/05/11 19:47:41 UTC
[celix] 02/02: Add callback data with ctx usage to celix_dependencyManager_createInfos
This is an automated email from the ASF dual-hosted git repository.
pnoltes pushed a commit to branch hotfix/remove-refresh-bundle-after-uninstall
in repository https://gitbox.apache.org/repos/asf/celix.git
commit 2a9aaa6a602eb7cc2d6bc1545ffd5d5cc2472e95
Author: Pepijn Noltes <pe...@gmail.com>
AuthorDate: Thu May 11 21:47:24 2023 +0200
Add callback data with ctx usage to celix_dependencyManager_createInfos
---
libs/framework/src/dm_dependency_manager_impl.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/libs/framework/src/dm_dependency_manager_impl.c b/libs/framework/src/dm_dependency_manager_impl.c
index d94214e8..0cf8a0e3 100644
--- a/libs/framework/src/dm_dependency_manager_impl.c
+++ b/libs/framework/src/dm_dependency_manager_impl.c
@@ -212,9 +212,14 @@ celix_dependency_manager_info_t* celix_dependencyManager_createInfo(celix_depend
return info;
}
+typedef struct celix_dm_get_info_callback_data {
+ celix_array_list_t *infos;
+ celix_bundle_context_t* ctx;
+} celix_dm_get_info_callback_data_t;
+
static void celix_dm_getInfosCallback(void *handle, const celix_bundle_t *bnd) {
- celix_array_list_t *infos = handle;
+ celix_dm_get_info_callback_data_t *data = handle;
celix_bundle_context_t *context = NULL;
bundle_getContext((celix_bundle_t*)bnd, &context);
@@ -234,7 +239,7 @@ static void celix_dm_getInfosCallback(void *handle, const celix_bundle_t *bnd) {
celix_dmComponent_getComponentInfo(cmp, &cmpInfo);
celix_arrayList_add(info->components, cmpInfo);
}
- celix_arrayList_add(infos, info);
+ celix_arrayList_add(data->infos, info);
celixThreadMutex_unlock(&mng->mutex);
}
@@ -245,13 +250,17 @@ static void celix_dependencyManager_destroyInfoCallback(void *data, celix_array_
}
celix_array_list_t * celix_dependencyManager_createInfos(celix_dependency_manager_t* manager) {
+ celix_dm_get_info_callback_data_t data;
+ data.ctx = manager->ctx;
+
celix_array_list_create_options_t opts = CELIX_EMPTY_ARRAY_LIST_CREATE_OPTIONS;
opts.removedCallbackData = manager;
opts.removedCallback = celix_dependencyManager_destroyInfoCallback;
- celix_array_list_t *infos = celix_arrayList_createWithOptions(&opts);
+ data.infos = celix_arrayList_createWithOptions(&opts);
celix_framework_t* fw = celix_bundleContext_getFramework(manager->ctx);
- celix_framework_useBundles(fw, true, infos, celix_dm_getInfosCallback);
- return infos;
+
+ celix_framework_useBundles(fw, true, &data, celix_dm_getInfosCallback);
+ return data.infos;
}
static void celix_dm_allComponentsActiveCallback(void *handle, const celix_bundle_t *bnd) {