PengZheng commented on code in PR #476:
URL: https://github.com/apache/celix/pull/476#discussion_r1155447692


##########
bundles/shell/shell/src/lb_command.c:
##########
@@ -49,16 +46,68 @@ typedef struct lb_options {
     char *listGroup;
 } lb_options_t;
 
-static char * psCommand_stateString(bundle_state_e state);
+typedef struct lb_command_bundle_info {
+    long id;
+    char* name;
+    char* symbolicName;
+    celix_version_t* version;
+    char* group;
+    char* location;
+    bundle_state_e state;
+} lb_command_bundle_info_t;
+
+static int lbCommand_bundleInfoCmp(const lb_command_bundle_info_t* a, const 
lb_command_bundle_info_t* b) {
+    return (int)(a->id - b->id);
+}
+
+static void lbCommand_collectBundleInfo_callback(void* data, const 
celix_bundle_t* bnd) {
+    celix_array_list_t* infoEntries = data;
+    lb_command_bundle_info_t* info = malloc(sizeof(*info));
+    if (info != NULL) {
+        info->id = celix_bundle_getId(bnd);
+        info->name = celix_utils_strdup(celix_bundle_getName(bnd));
+        info->location = celix_utils_strdup(celix_bundle_getLocation(bnd));
+        info->symbolicName = 
celix_utils_strdup(celix_bundle_getSymbolicName(bnd));
+        info->version = celix_version_copy(celix_bundle_getVersion(bnd));
+        info->group = celix_utils_strdup(celix_bundle_getGroup(bnd));
+        info->state = celix_bundle_getState(bnd);
+    }
+    celix_arrayList_add(infoEntries, info);
+}
+
+static celix_array_list_t* lbCommand_collectBundleInfo(celix_bundle_context_t 
*ctx) {
+    celix_array_list_t* infoEntries = celix_arrayList_create();

Review Comment:
   Use `celix_arrayList_createWithOptions` so that we can use `removedCallback` 
instead of `lbCommand_freeBundleInfoEntries` to avoid iterating over the list.



-- 
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

Reply via email to