component/bt: Fix bug of bt dynamic memory
This commit is contained in:
parent
a58a2b6f6d
commit
3ee5b49575
9 changed files with 146 additions and 2 deletions
|
@ -173,7 +173,6 @@ void BTE_InitStack(void)
|
||||||
#endif // PAN
|
#endif // PAN
|
||||||
#endif // BNEP Included
|
#endif // BNEP Included
|
||||||
|
|
||||||
|
|
||||||
//AVDT and its profiles
|
//AVDT and its profiles
|
||||||
#if (defined(A2D_INCLUDED) && A2D_INCLUDED == TRUE)
|
#if (defined(A2D_INCLUDED) && A2D_INCLUDED == TRUE)
|
||||||
A2D_Init();
|
A2D_Init();
|
||||||
|
@ -229,6 +228,12 @@ void BTE_InitStack(void)
|
||||||
memset((void *)bta_dm_di_cb_ptr, 0, sizeof(tBTA_DM_DI_CB));
|
memset((void *)bta_dm_di_cb_ptr, 0, sizeof(tBTA_DM_DI_CB));
|
||||||
//memset((void *)bta_prm_cb_ptr, 0, sizeof(tBTA_PRM_CB));
|
//memset((void *)bta_prm_cb_ptr, 0, sizeof(tBTA_PRM_CB));
|
||||||
//memset((void *)bta_ag_cb_ptr, 0, sizeof(tBTA_AG_CB));
|
//memset((void *)bta_ag_cb_ptr, 0, sizeof(tBTA_AG_CB));
|
||||||
|
#if (defined BTA_JV_INCLUDED && BTA_JV_INCLUDED == TRUE)
|
||||||
|
if ((bta_jv_cb_ptr = (tBTA_JV_CB *)osi_malloc(sizeof(tBTA_JV_CB))) == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
memset((void *)bta_jv_cb_ptr, 0, sizeof(tBTA_JV_CB));
|
||||||
|
#endif //JV
|
||||||
#if BTA_HS_INCLUDED == TRUE
|
#if BTA_HS_INCLUDED == TRUE
|
||||||
memset((void *)bta_hs_cb_ptr, 0, sizeof(tBTA_HS_CB));
|
memset((void *)bta_hs_cb_ptr, 0, sizeof(tBTA_HS_CB));
|
||||||
#endif
|
#endif
|
||||||
|
@ -277,3 +282,76 @@ void BTE_InitStack(void)
|
||||||
|
|
||||||
#endif // BTA_INCLUDED == TRUE
|
#endif // BTA_INCLUDED == TRUE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
**
|
||||||
|
** Function BTE_DeinitStack
|
||||||
|
**
|
||||||
|
** Description Deinitialize control block memory for each component.
|
||||||
|
**
|
||||||
|
** Note: This API must be called
|
||||||
|
** after freeing the BTU Task.
|
||||||
|
**
|
||||||
|
** Returns void
|
||||||
|
**
|
||||||
|
******************************************************************************/
|
||||||
|
void BTE_DeinitStack(void)
|
||||||
|
{
|
||||||
|
//BTA Modules
|
||||||
|
#if (BTA_INCLUDED == TRUE && BTA_DYNAMIC_MEMORY == TRUE)
|
||||||
|
#if GATTS_INCLUDED == TRUE
|
||||||
|
osi_free(bta_gatts_cb_ptr);
|
||||||
|
bta_gatts_cb_ptr = NULL;
|
||||||
|
#endif
|
||||||
|
#if GATTC_INCLUDED==TRUE
|
||||||
|
osi_free(bta_gattc_cb_ptr);
|
||||||
|
bta_gattc_cb_ptr = NULL;
|
||||||
|
#endif
|
||||||
|
#if BTA_HH_INCLUDED==TRUE
|
||||||
|
osi_free(bta_hh_cb_ptr);
|
||||||
|
bta_hh_cb_ptr = NULL;
|
||||||
|
#endif
|
||||||
|
#if BTA_AV_INCLUDED==TRUE
|
||||||
|
osi_free(bta_av_cb_ptr);
|
||||||
|
bta_av_cb_ptr = NULL;
|
||||||
|
#endif
|
||||||
|
#if BTA_AR_INCLUDED==TRUE
|
||||||
|
osi_free(bta_ar_cb_ptr);
|
||||||
|
bta_ar_cb_ptr = NULL;
|
||||||
|
#endif
|
||||||
|
#if BTA_SDP_INCLUDED == TRUE
|
||||||
|
osi_free(bta_sdp_cb_ptr);
|
||||||
|
bta_sdp_cb_ptr = NULL;
|
||||||
|
#endif
|
||||||
|
#if (defined BTA_JV_INCLUDED && BTA_JV_INCLUDED == TRUE)
|
||||||
|
osi_free(bta_jv_cb_ptr);
|
||||||
|
bta_jv_cb_ptr = NULL;
|
||||||
|
#endif //JV
|
||||||
|
osi_free(bta_dm_di_cb_ptr);
|
||||||
|
bta_dm_di_cb_ptr = NULL;
|
||||||
|
osi_free(bta_dm_search_cb_ptr);
|
||||||
|
bta_dm_search_cb_ptr = NULL;
|
||||||
|
osi_free(bta_dm_cb_ptr);
|
||||||
|
bta_dm_cb_ptr = NULL;
|
||||||
|
osi_free(bta_sys_cb_ptr);
|
||||||
|
bta_sys_cb_ptr = NULL;
|
||||||
|
#endif // BTA_INCLUDED == TRUE
|
||||||
|
|
||||||
|
#if (defined(AVCT_INCLUDED) && AVCT_INCLUDED == TRUE && AVCT_DYNAMIC_MEMORY == TRUE)
|
||||||
|
osi_free(avct_cb_ptr);
|
||||||
|
avct_cb_ptr = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (defined(AVDT_INCLUDED) && AVDT_INCLUDED == TRUE && AVDT_DYNAMIC_MEMORY == TRUE)
|
||||||
|
osi_free(avdt_cb_ptr);
|
||||||
|
avdt_cb_ptr = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (defined(AVRC_INCLUDED) && AVRC_INCLUDED == TRUE)
|
||||||
|
AVRC_Deinit();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (defined(A2D_INCLUDED) && A2D_INCLUDED == TRUE)
|
||||||
|
A2D_Deinit();
|
||||||
|
#endif
|
||||||
|
}
|
|
@ -391,4 +391,22 @@ void A2D_Init(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
** Function A2D_Deinit
|
||||||
|
**
|
||||||
|
** Description This function is called to deinitialize the control block
|
||||||
|
** for this layer.
|
||||||
|
**
|
||||||
|
** Returns void
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
void A2D_Deinit(void)
|
||||||
|
{
|
||||||
|
#if (A2D_DYNAMIC_MEMORY)
|
||||||
|
osi_free(a2d_cb_ptr);
|
||||||
|
a2d_cb_ptr = NULL;
|
||||||
|
#endif /* #if (A2D_DYNAMIC_MEMORY) */
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* #if (defined(A2D_INCLUDED) && A2D_INCLUDED == TRUE) */
|
#endif /* #if (defined(A2D_INCLUDED) && A2D_INCLUDED == TRUE) */
|
||||||
|
|
|
@ -357,4 +357,23 @@ void AVRC_Init(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
** Function AVRC_Deinit
|
||||||
|
**
|
||||||
|
** Description This function is called at stack shotdown to free the
|
||||||
|
** control block (if using dynamic memory), and deinitializes the
|
||||||
|
** control block and tracing level.
|
||||||
|
**
|
||||||
|
** Returns void
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
void AVRC_Deinit(void)
|
||||||
|
{
|
||||||
|
#if AVRC_DYNAMIC_MEMORY
|
||||||
|
osi_free(avrc_cb_ptr);
|
||||||
|
avrc_cb_ptr = NULL;
|
||||||
|
#endif /* #if AVRC_DYNAMIC_MEMORY */
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* #if (defined(AVRC_INCLUDED) && AVRC_INCLUDED == TRUE) */
|
#endif /* #if (defined(AVRC_INCLUDED) && AVRC_INCLUDED == TRUE) */
|
||||||
|
|
|
@ -118,6 +118,10 @@ void btu_free_core(void)
|
||||||
// Free the mandatory core stack components
|
// Free the mandatory core stack components
|
||||||
l2c_free();
|
l2c_free();
|
||||||
|
|
||||||
|
#if (defined(SDP_INCLUDED) && SDP_INCLUDED == TRUE)
|
||||||
|
sdp_deinit();
|
||||||
|
#endif
|
||||||
|
|
||||||
#if BLE_INCLUDED == TRUE
|
#if BLE_INCLUDED == TRUE
|
||||||
#if (defined(GATT_INCLUDED) && GATT_INCLUDED == true)
|
#if (defined(GATT_INCLUDED) && GATT_INCLUDED == true)
|
||||||
gatt_free();
|
gatt_free();
|
||||||
|
|
|
@ -86,6 +86,7 @@ extern void avdt_rcv_sync_info (BT_HDR *p_buf);
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
extern void BTE_InitStack(void);
|
extern void BTE_InitStack(void);
|
||||||
|
extern void BTE_DeinitStack(void);
|
||||||
|
|
||||||
/* Define BTU storage area
|
/* Define BTU storage area
|
||||||
*/
|
*/
|
||||||
|
@ -314,6 +315,7 @@ void btu_task_shut_down(void)
|
||||||
#if (defined(BTA_INCLUDED) && BTA_INCLUDED == TRUE)
|
#if (defined(BTA_INCLUDED) && BTA_INCLUDED == TRUE)
|
||||||
bta_sys_free();
|
bta_sys_free();
|
||||||
#endif
|
#endif
|
||||||
|
BTE_DeinitStack();
|
||||||
|
|
||||||
btu_free_core();
|
btu_free_core();
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,5 +251,6 @@ extern UINT8 A2D_BitsSet(UINT8 num);
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
extern void A2D_Init(void);
|
extern void A2D_Init(void);
|
||||||
|
extern void A2D_Deinit(void);
|
||||||
#endif ///A2D_INCLUDED
|
#endif ///A2D_INCLUDED
|
||||||
#endif /* A2D_API_H */
|
#endif /* A2D_API_H */
|
||||||
|
|
|
@ -554,6 +554,19 @@ extern UINT8 AVRC_SetTraceLevel (UINT8 new_level);
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
extern void AVRC_Init(void);
|
extern void AVRC_Init(void);
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
** Function AVRC_Deinit
|
||||||
|
**
|
||||||
|
** Description This function is called at stack shotdown to free the
|
||||||
|
** control block (if using dynamic memory), and deinitializes the
|
||||||
|
** control block and tracing level.
|
||||||
|
**
|
||||||
|
** Returns void
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
extern void AVRC_Deinit(void);
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
** Function AVRC_ParsCommand
|
** Function AVRC_ParsCommand
|
||||||
|
|
|
@ -237,6 +237,7 @@ extern tSDP_CB *sdp_cb_ptr;
|
||||||
|
|
||||||
/* Functions provided by sdp_main.c */
|
/* Functions provided by sdp_main.c */
|
||||||
extern void sdp_init (void);
|
extern void sdp_init (void);
|
||||||
|
extern void sdp_deinit (void);
|
||||||
extern void sdp_disconnect (tCONN_CB *p_ccb, UINT16 reason);
|
extern void sdp_disconnect (tCONN_CB *p_ccb, UINT16 reason);
|
||||||
|
|
||||||
#if (defined(SDP_DEBUG) && SDP_DEBUG == TRUE)
|
#if (defined(SDP_DEBUG) && SDP_DEBUG == TRUE)
|
||||||
|
|
|
@ -138,6 +138,14 @@ void sdp_init (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sdp_deinit (void)
|
||||||
|
{
|
||||||
|
#if SDP_DYNAMIC_MEMORY
|
||||||
|
osi_free(sdp_cb_ptr);
|
||||||
|
sdp_cb_ptr = NULL;
|
||||||
|
#endif /* #if SDP_DYNAMIC_MEMORY */
|
||||||
|
}
|
||||||
|
|
||||||
#if (defined(SDP_DEBUG) && SDP_DEBUG == TRUE)
|
#if (defined(SDP_DEBUG) && SDP_DEBUG == TRUE)
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
|
|
Loading…
Reference in a new issue