g_free(gattc_data);
}
-void __hal_gattc_free_svc_info(hal_gattc_service_t *svc_info)
+static void __hal_gattc_free_desc_info(hal_gattc_desc_t *desc_info)
{
- g_free(svc_info->svc_path);
- g_free(svc_info);
+ g_free(desc_info->desc_path);
+ g_free(desc_info);
}
-void __hal_gattc_free_char_info(hal_gattc_char_t *char_info)
+static void __hal_gattc_free_char_info(hal_gattc_char_t *char_info)
{
+ GSList *l = NULL;
+ hal_gattc_desc_t *desc_info = NULL;
+ for (l = char_info->gatt_list_descs; l != NULL; ) {
+ desc_info = l->data;
+ l = g_slist_next(l);
+ if (desc_info == NULL)
+ continue;
+ /* Remove descriptor element */
+ char_info->gatt_list_descs = g_slist_remove(char_info->gatt_list_descs, desc_info);
+ __hal_gattc_free_desc_info(desc_info);
+ }
+ g_slist_free(char_info->gatt_list_descs);
g_free(char_info->chr_path);
g_free(char_info);
}
-void __hal_gattc_free_desc_info(hal_gattc_desc_t *desc_info)
+static void __hal_gattc_free_svc_info(hal_gattc_service_t *svc_info)
{
- g_free(desc_info->desc_path);
- g_free(desc_info);
+ GSList *l = NULL;
+ hal_gattc_char_t *char_info = NULL;
+ for (l = svc_info->gatt_list_chars; l != NULL; ) {
+ char_info = l->data;
+ l = g_slist_next(l);
+ if (char_info == NULL)
+ continue;
+ /* Remove characteristic element */
+ svc_info->gatt_list_chars = g_slist_remove(svc_info->gatt_list_chars, char_info);
+ __hal_gattc_free_char_info(char_info);
+ }
+ g_slist_free(svc_info->gatt_list_chars);
+ g_free(svc_info->svc_path);
+ g_free(svc_info);
}
-void __hal_clean_gattc_server_info(hal_gattc_server_info_t *conn_info)
+static void __hal_clean_gattc_server_info(hal_gattc_server_info_t *conn_info)
{
- GSList *l;
- GSList *m;
- GSList *k;
+ GSList *l = NULL;
hal_gattc_service_t *svc_info = NULL;
- hal_gattc_char_t *char_info = NULL;
- hal_gattc_desc_t *desc_info = NULL;
DBG("+");
- for (l = conn_info->gatt_list_services; l != NULL;) {
- svc_info = (hal_gattc_service_t*)l->data;
+ for (l = conn_info->gatt_list_services; l != NULL; ) {
+ svc_info = (hal_gattc_service_t *)l->data;
+ l = g_slist_next(l);
if (svc_info == NULL)
continue;
- l = g_slist_next(l);
-
- for (m = svc_info->gatt_list_chars; m != NULL; ) {
- char_info = (hal_gattc_char_t*)m->data;
- if (char_info == NULL)
- continue;
- m = g_slist_next(m);
-
- for (k = char_info->gatt_list_descs; k != NULL; ) {
- desc_info = (hal_gattc_desc_t*)k->data;
- if (desc_info == NULL)
- continue;
- k = g_slist_next(k);
-
- /*remove desc element*/
- char_info->gatt_list_descs = g_slist_remove(char_info->gatt_list_descs, desc_info);
- __hal_gattc_free_desc_info(desc_info);
- }
-
- /*remove desc list*/
- g_slist_free(char_info->gatt_list_descs);
- char_info->gatt_list_descs = NULL;
-
- /*remove char element*/
- svc_info->gatt_list_chars = g_slist_remove(svc_info->gatt_list_chars, char_info);
- __hal_gattc_free_char_info(char_info);
- }
-
- /*remove char list*/
- g_slist_free(svc_info->gatt_list_chars);
- svc_info->gatt_list_chars = NULL;
-
- /*remove svc element*/
+ /* Remove service element */
conn_info->gatt_list_services = g_slist_remove(conn_info->gatt_list_services, svc_info);
__hal_gattc_free_svc_info(svc_info);
}
-
- /*remove svc list */
g_slist_free(conn_info->gatt_list_services);
- conn_info->gatt_list_services = NULL;
-
- /*remove conn info*/
g_free(conn_info);
}