Commit 9df3192b authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by Andre Eisenbach
Browse files

Use dynamic memory for keeping GATT cache

Change-Id: I60674c47246d8fe2094fe78ce31b752fa2acb89e
parent 3c30f80c
......@@ -1038,12 +1038,8 @@ void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
if (p_clcb->status != GATT_SUCCESS)
{
/* clean up cache */
if(p_clcb->p_srcb && p_clcb->p_srcb->p_srvc_cache)
{
while (! fixed_queue_is_empty(p_clcb->p_srcb->cache_buffer))
{
osi_freebuf(fixed_queue_try_dequeue(p_clcb->p_srcb->cache_buffer));
}
if(p_clcb->p_srcb && p_clcb->p_srcb->p_srvc_cache) {
list_free(p_clcb->p_srcb->p_srvc_cache);
p_clcb->p_srcb->p_srvc_cache = NULL;
}
......@@ -1909,11 +1905,8 @@ void bta_gattc_process_api_refresh(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg)
}
}
/* in all other cases, mark it and delete the cache */
if (p_srvc_cb->p_srvc_cache != NULL)
{
while (! fixed_queue_is_empty(p_srvc_cb->cache_buffer))
osi_freebuf(fixed_queue_try_dequeue(p_srvc_cb->cache_buffer));
if (p_srvc_cb->p_srvc_cache != NULL) {
list_free(p_srvc_cb->p_srvc_cache);
p_srvc_cb->p_srvc_cache = NULL;
}
}
......
This diff is collapsed.
......@@ -254,10 +254,9 @@ typedef union
UINT16 uuid16;
}tBTA_GATTC_UUID;
typedef struct gattc_attr_cache
typedef struct
{
tBTA_GATTC_UUID *p_uuid;
struct gattc_attr_cache *p_next;
UINT16 uuid_len;
UINT16 attr_handle;
UINT8 inst_id;
......@@ -269,15 +268,13 @@ typedef struct gattc_attr_cache
} __attribute__((packed)) tBTA_GATTC_CACHE_ATTR;
// btla-specific --
typedef struct gattc_svc_cache
typedef struct
{
tBTA_GATT_SRVC_ID service_uuid;
tBTA_GATTC_CACHE_ATTR *p_attr;
tBTA_GATTC_CACHE_ATTR *p_last_attr;
list_t *p_attr; /* list of tBTA_GATTC_CACHE_ATTR */
UINT16 s_handle;
UINT16 e_handle;
struct gattc_svc_cache *p_next;
tBTA_GATTC_CACHE_ATTR *p_cur_char;
list_node_t *p_cur_char; /* node pointing to p_attr */
// btla-specific ++
} __attribute__((packed)) tBTA_GATTC_CACHE;
// btla-specific --
......@@ -323,11 +320,8 @@ typedef struct
UINT8 state;
tBTA_GATTC_CACHE *p_srvc_cache;
list_t *p_srvc_cache; /* list of tBTA_GATTC_CACHE */
tBTA_GATTC_CACHE *p_cur_srvc;
fixed_queue_t *cache_buffer; /* buffer queue used for storing the cache data */
UINT8 *p_free; /* starting point to next available byte */
UINT16 free_byte; /* number of available bytes in server cache buffer */
UINT8 update_count; /* indication received */
UINT8 num_clcb; /* number of associated CLCB */
......
......@@ -410,15 +410,8 @@ tBTA_GATTC_SERV * bta_gattc_srcb_alloc(BD_ADDR bda)
if (p_tcb != NULL)
{
if (p_tcb->cache_buffer != NULL) {
while (! fixed_queue_is_empty(p_tcb->cache_buffer))
osi_freebuf(fixed_queue_try_dequeue(p_tcb->cache_buffer));
fixed_queue_free(p_tcb->cache_buffer, NULL);
}
osi_freebuf_and_reset((void **)&p_tcb->p_srvc_list);
memset(p_tcb, 0 , sizeof(tBTA_GATTC_SERV));
p_tcb->cache_buffer = fixed_queue_new(SIZE_MAX);
p_tcb->in_use = TRUE;
bdcpy(p_tcb->server_bda, bda);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment