Init hal gatt resources when bt is enabled 44/238644/1
authorDeokhyun Kim <dukan.kim@samsung.com>
Wed, 15 Jul 2020 08:15:48 +0000 (17:15 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Thu, 16 Jul 2020 04:31:17 +0000 (13:31 +0900)
Change-Id: I4c97c403c69973c3e083675336b919d54ad37c8b
Signed-off-by: Deokhyun Kim <dukan.kim@samsung.com>
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
bt-oal/bluez_hal/src/bt-hal-gatt-server.c

index 2345791..02fe240 100644 (file)
@@ -342,10 +342,35 @@ static const gchar manager_introspection_xml[] =
 "  </interface>"
 "</node>";
 
+static void __bt_free_gatt_server_app(struct gatt_server_app *app)
+{
+       g_free(app->app_path);
+       g_free(app);
+}
+
+static void __bt_hal_gatt_free_service_info(struct gatt_service_info *svc_info)
+{
+       if (!svc_info)
+               return;
+
+       g_free(svc_info->serv_path);
+       g_free(svc_info->service_uuid);
+       g_free(svc_info);
+}
+
 void _bt_hal_gatt_server_init(void)
 {
        assigned_id = 0;
        memset(instance_id_used, 0x00, sizeof(instance_id_used));
+
+       g_slist_free_full(gatt_server_apps, (GDestroyNotify)__bt_free_gatt_server_app);
+       gatt_server_apps = NULL;
+
+       g_slist_free_full(gatt_services, (GDestroyNotify)__bt_hal_gatt_free_service_info);
+       gatt_services = NULL;
+
+       g_slist_free_full(hal_gatts_server_register_list, g_free);
+       hal_gatts_server_register_list = NULL;
 }
 
 static int __bt_hal_gatt_assign_id(void)
@@ -1589,17 +1614,6 @@ static void __bt_hal_gatt_free_characteristic_info(struct gatt_char_info *char_i
        g_free(char_info);
 }
 
-
-static void __bt_hal_gatt_free_service_info(struct gatt_service_info *svc_info)
-{
-       if (!svc_info)
-               return;
-
-       g_free(svc_info->serv_path);
-       g_free(svc_info->service_uuid);
-       g_free(svc_info);
-}
-
 static const GDBusInterfaceVTable desc_interface_vtable = {
        __bt_gatt_desc_method_call,
        NULL,