mirror of
https://github.com/raspberrypi/pico-sdk.git
synced 2025-03-14 04:18:33 +00:00
Allow malloc and free to be changed. (#1309)
Bluetooth needs a tempoarary buffer to load firmware. Micropython won't work safely with malloc and free so allow these calls to be changed by using cyw43_malloc / cyw43_free macros.
This commit is contained in:
parent
2bfa90ccbb
commit
4000c9f414
@ -62,14 +62,14 @@ static cybt_result_t cybt_fw_download_prepare(uint8_t **p_write_buf, uint8_t **p
|
||||
*p_write_buf = NULL;
|
||||
*p_hex_buf = NULL;
|
||||
|
||||
*p_write_buf = malloc(BTFW_DOWNLOAD_BLK_SIZE + BTFW_SD_ALIGN);
|
||||
*p_write_buf = cyw43_malloc(BTFW_DOWNLOAD_BLK_SIZE + BTFW_SD_ALIGN);
|
||||
if (NULL == *p_write_buf) {
|
||||
return CYBT_ERR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
*p_hex_buf = malloc(BTFW_MAX_STR_LEN);
|
||||
*p_hex_buf = cyw43_malloc(BTFW_MAX_STR_LEN);
|
||||
if (NULL == *p_hex_buf) {
|
||||
free(*p_write_buf);
|
||||
cyw43_free(*p_write_buf);
|
||||
return CYBT_ERR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
@ -78,11 +78,11 @@ static cybt_result_t cybt_fw_download_prepare(uint8_t **p_write_buf, uint8_t **p
|
||||
|
||||
static cybt_result_t cybt_fw_download_finish(uint8_t *p_write_buf, uint8_t *p_hex_buf) {
|
||||
if (p_write_buf) {
|
||||
free(p_write_buf);
|
||||
cyw43_free(p_write_buf);
|
||||
}
|
||||
|
||||
if (p_hex_buf) {
|
||||
free(p_hex_buf);
|
||||
cyw43_free(p_hex_buf);
|
||||
}
|
||||
|
||||
return CYBT_SUCCESS;
|
||||
|
@ -157,6 +157,14 @@ void cyw43_post_poll_hook(void);
|
||||
|
||||
#define CYW43_POST_POLL_HOOK cyw43_post_poll_hook();
|
||||
|
||||
// Allow malloc and free to be changed
|
||||
#ifndef cyw43_malloc
|
||||
#define cyw43_malloc malloc
|
||||
#endif
|
||||
#ifndef cyw43_free
|
||||
#define cyw43_free free
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user