From: baohongde Date: Wed, 13 Feb 2019 02:38:26 +0000 (+0800) Subject: components/bt: Optimization and bugfix of previous commit X-Git-Tag: v4.0-beta1~197^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9863565a6f3d38b3a0857b7135b652d7106dd7c3;p=esp-idf components/bt: Optimization and bugfix of previous commit --- diff --git a/components/bt/bluedroid/bta/gatt/bta_gattc_co.c b/components/bt/bluedroid/bta/gatt/bta_gattc_co.c index 98444458ae..06c51b07e8 100644 --- a/components/bt/bluedroid/bta/gatt/bta_gattc_co.c +++ b/components/bt/bluedroid/bta/gatt/bta_gattc_co.c @@ -96,7 +96,7 @@ typedef struct { cache_addr_info_t cache_addr[MAX_DEVICE_IN_CACHE]; }cache_env_t; -cache_env_t *cache_env = NULL; +static cache_env_t *cache_env = NULL; static void getFilename(char *buffer, hash_key_t hash) { @@ -382,10 +382,15 @@ void bta_gattc_co_cache_addr_init(void) UINT8 num_addr; size_t length = MAX_ADDR_LIST_CACHE_BUF; UINT8 *p_buf = osi_malloc(MAX_ADDR_LIST_CACHE_BUF); + if (p_buf == NULL) { + APPL_TRACE_ERROR("%s malloc failed!", __func__); + return; + } cache_env = (cache_env_t *)osi_malloc(sizeof(cache_env_t)); - if (cache_env == NULL || p_buf == NULL) { + if (cache_env == NULL) { APPL_TRACE_ERROR("%s malloc failed!", __func__); + osi_free(p_buf); return; } diff --git a/components/bt/bluedroid/btc/core/btc_config.c b/components/bt/bluedroid/btc/core/btc_config.c index b987a32e0c..fdababfe08 100644 --- a/components/bt/bluedroid/btc/core/btc_config.c +++ b/components/bt/bluedroid/btc/core/btc_config.c @@ -336,5 +336,4 @@ void btc_config_lock(void) void btc_config_unlock(void) { osi_mutex_unlock(&lock); -} - +} \ No newline at end of file