return BM_PLUGIN_ERROR_NONE;
}
+static void free_app_list(GSList *app_list)
+{
+ GSList *l = NULL;
+ app_time_map_st2 *app_info;
+ for (l = app_list; l != NULL; l = g_slist_next(l)){
+ app_info = (app_time_map_st2 *)(l->data);
+ if (app_info != NULL)
+ free(app_info->app_id);
+ }
+ g_slist_free(app_list);
+}
+
int get_feature_data(bm_data_h *handle, bm_plugin_data_type_e type)
{
ENTER;
bm_bluetooth_st *bluetooth_record = NULL;
app_time_map_st2 *app_record = NULL;
- bluetooth_record_head = (bm_bluetooth_st *)calloc(1, sizeof(bm_bluetooth_st));
- if (bluetooth_record_head == NULL) {
- _E("Calloc Failed");
- return BM_PLUGIN_ERROR_OUT_OF_MEMORY;
- }
-
- bluetooth_record = (bm_bluetooth_st*)calloc(1, sizeof(bm_bluetooth_st));
+ bluetooth_record = (bm_bluetooth_st *)calloc(1, sizeof(bm_bluetooth_st));
if (bluetooth_record == NULL) {
_E("Calloc Failed");
return BM_PLUGIN_ERROR_OUT_OF_MEMORY;
if (ret != 0)
{
_E("battery info not read");
+ free(bluetooth_record);
return BM_PLUGIN_ERROR_NO_DATA;
}
/* Getting app data */
GSList *app_list = NULL, *l = NULL;
app_list = bluetooth_record->atm_list;
- bt_battery_app_info_s *app_info;
+ bt_battery_app_info_s *app_info = NULL;
for (l = battery_data.atm_list; l != NULL; l = g_slist_next(l)) {
- app_record = (app_time_map_st2*)calloc(1, sizeof(app_time_map_st2));
+ app_record = (app_time_map_st2 *)calloc(1, sizeof(app_time_map_st2));
if (app_record == NULL) {
_E("Calloc Failed");
+ free_app_list(bluetooth_record->atm_list);
+ free(bluetooth_record);
return BM_PLUGIN_ERROR_OUT_OF_MEMORY;
}
app_info = (bt_battery_app_info_s *)(l->data);
if (app_info == NULL) {
_E("app_info is NULL");
+ free_app_list(bluetooth_record->atm_list);
+ free(bluetooth_record);
return BM_PLUGIN_ERROR_NO_DATA;
}
}
/*Append BT data to head node as per design doc*/
+ bluetooth_record_head = (bm_bluetooth_st *)calloc(1, sizeof(bm_bluetooth_st));
+ if (bluetooth_record_head == NULL) {
+ _E("Calloc Failed");
+ free_app_list(bluetooth_record->atm_list);
+ free(bluetooth_record);
+ return BM_PLUGIN_ERROR_OUT_OF_MEMORY;
+ }
bluetooth_record_head->bt_data_list = g_slist_append(
bluetooth_record_head->bt_data_list, bluetooth_record);
*handle = bluetooth_record_head;