stegemr commented on code in PR #476: URL: https://github.com/apache/celix/pull/476#discussion_r1148388058
########## libs/framework/src/bundle.c: ########## @@ -24,76 +24,61 @@ #include <service_tracker.h> #include <celix_constants.h> #include <assert.h> +#include <unistd.h> #include "framework_private.h" #include "resolver.h" #include "utils.h" +#include "celix_file_utils.h" #include "bundle_archive_private.h" - #include "bundle_context_private.h" #include "service_tracker_private.h" +static char* celix_bundle_getBundleOrPersistentStoreEntry(const celix_bundle_t* bnd, bool bundleEntry, const char* name); celix_status_t bundle_createModule(bundle_pt bundle, module_pt *module); celix_status_t bundle_closeRevisions(const_bundle_pt bundle); -celix_status_t bundle_create(celix_framework_t* fw, bundle_pt * bundle) { - celix_status_t status; - bundle_archive_pt archive = NULL; - - *bundle = (bundle_pt) calloc(1, sizeof(**bundle)); - if (*bundle == NULL) { - return CELIX_ENOMEM; - } - status = bundleArchive_createSystemBundleArchive(fw, &archive); - if (status == CELIX_SUCCESS) { - module_pt module; - - (*bundle)->archive = archive; - (*bundle)->activator = NULL; - (*bundle)->context = NULL; - (*bundle)->framework = fw; - (*bundle)->state = CELIX_BUNDLE_STATE_INSTALLED; - (*bundle)->modules = NULL; - arrayList_create(&(*bundle)->modules); - (*bundle)->handle = NULL; - - module = module_createFrameworkModule((*bundle)); - bundle_addModule(*bundle, module); +celix_status_t celix_bundle_createFromArchive(celix_framework_t *framework, bundle_archive_pt archive, celix_bundle_t **bundleOut) { + celix_status_t status = CELIX_SUCCESS; + celix_bundle_t* bundle = calloc(1, sizeof(*bundle)); - } - framework_logIfError(celix_frameworkLogger_globalLogger(), status, NULL, "Failed to create bundle"); + if (!bundle) { + status = CELIX_ENOMEM; + fw_logCode(framework->logger, CELIX_LOG_LEVEL_ERROR, status, "Cannot create bundle from archive, out of memory."); + return status; + } - return status; -} + bundle->framework = framework; + bundle->archive = archive; + bundle->modules = celix_arrayList_create(); + bundle->state = OSGI_FRAMEWORK_BUNDLE_INSTALLED; + bundle->handle = NULL; + bundle->activator = NULL; + bundle->context = NULL; + bundle->symbolicName = NULL; + bundle->name = NULL; + bundle->group = NULL; + bundle->description = NULL; + + if (bundle->modules == NULL) { + status = CELIX_ENOMEM; + fw_logCode(framework->logger, CELIX_LOG_LEVEL_ERROR, status, "Cannot create bundle from archive, out of memory."); + return status; Review Comment: Leak, free bundle missing -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@celix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org