Skip to content

Commit

Permalink
Remove unnecessary memory allocation for getting version string.
Browse files Browse the repository at this point in the history
  • Loading branch information
PengZheng committed Nov 16, 2024
1 parent d10a983 commit fff61fc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
5 changes: 3 additions & 2 deletions libs/framework/src/bundle_archive.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ static celix_status_t celix_bundleArchive_storeBundleStateProperties(bundle_arch
}

celix_bundle_manifest_t* man = celix_bundleArchive_getManifest(archive);
celix_autofree char* bndVersion = celix_version_toString(celix_bundleManifest_getBundleVersion(man));
const char* bndVersion = celix_properties_getAsString(celix_bundleManifest_getAttributes(man),
CELIX_BUNDLE_VERSION, "");

if (!bundleStateProperties || !bndVersion) {
if (!bundleStateProperties) {
return CELIX_ENOMEM;
}

Expand Down
12 changes: 0 additions & 12 deletions libs/framework/src/celix_bundle_manifest.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,6 @@
#include <string.h>
#include <stdlib.h>

// Mandatory manifest attributes
#define CELIX_BUNDLE_MANIFEST_VERSION "CELIX_BUNDLE_MANIFEST_VERSION"
#define CELIX_BUNDLE_SYMBOLIC_NAME "CELIX_BUNDLE_SYMBOLIC_NAME"
#define CELIX_BUNDLE_VERSION "CELIX_BUNDLE_VERSION"
#define CELIX_BUNDLE_NAME "CELIX_BUNDLE_NAME"

// Optional manifest attributes
#define CELIX_BUNDLE_ACTIVATOR_LIBRARY "CELIX_BUNDLE_ACTIVATOR_LIBRARY"
#define CELIX_BUNDLE_PRIVATE_LIBRARIES "CELIX_BUNDLE_PRIVATE_LIBRARIES"
#define CELIX_BUNDLE_DESCRIPTION "CELIX_BUNDLE_DESCRIPTION"
#define CELIX_BUNDLE_GROUP "CELIX_BUNDLE_GROUP"

#define CELIX_BUNDLE_SYMBOLIC_NAME_ALLOWED_SPECIAL_CHARS "-_:."
#define CELIX_FRAMEWORK_MANIFEST_VERSION "2.0.0"

Expand Down
12 changes: 12 additions & 0 deletions libs/framework/src/celix_bundle_manifest.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@
extern "C" {
#endif

// Mandatory manifest attributes
#define CELIX_BUNDLE_MANIFEST_VERSION "CELIX_BUNDLE_MANIFEST_VERSION"
#define CELIX_BUNDLE_SYMBOLIC_NAME "CELIX_BUNDLE_SYMBOLIC_NAME"
#define CELIX_BUNDLE_VERSION "CELIX_BUNDLE_VERSION"
#define CELIX_BUNDLE_NAME "CELIX_BUNDLE_NAME"

// Optional manifest attributes
#define CELIX_BUNDLE_ACTIVATOR_LIBRARY "CELIX_BUNDLE_ACTIVATOR_LIBRARY"
#define CELIX_BUNDLE_PRIVATE_LIBRARIES "CELIX_BUNDLE_PRIVATE_LIBRARIES"
#define CELIX_BUNDLE_DESCRIPTION "CELIX_BUNDLE_DESCRIPTION"
#define CELIX_BUNDLE_GROUP "CELIX_BUNDLE_GROUP"

/**
* @file celix_bundle_manifest.h
* @brief Header file for celix_bundle_manifest_t.
Expand Down

0 comments on commit fff61fc

Please sign in to comment.