Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 8e08fab

Browse files
committed
Replaced heap_caps_malloc/free with malloc/free.
1 parent a106cb4 commit 8e08fab

File tree

9 files changed

+24
-24
lines changed

9 files changed

+24
-24
lines changed

esp32/fatfs/src/drivers/sflash_diskio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ DRESULT sflash_disk_init (void) {
5454
sflash_start_address = SFLASH_START_ADDR_4MB;
5555
sflash_fs_sector_count = SFLASH_FS_SECTOR_COUNT_4MB;
5656
}
57-
sflash_block_cache = (uint8_t *)heap_caps_malloc(SFLASH_BLOCK_SIZE, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
57+
sflash_block_cache = (uint8_t *)malloc(SFLASH_BLOCK_SIZE);
5858
sflash_prev_block_addr = UINT32_MAX;
5959
sflash_cache_is_dirty = false;
6060
sflash_init_done = true;

esp32/ftp/ftp.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -614,10 +614,10 @@ static void ftp_return_to_previous_path (char *pwd, char *dir);
614614
******************************************************************************/
615615
void ftp_init (void) {
616616
// allocate memory for the data buffer, and the file system structs (from the RTOS heap)
617-
ftp_data.dBuffer = heap_caps_malloc(FTP_BUFFER_SIZE, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
618-
ftp_path = heap_caps_malloc(FTP_MAX_PARAM_SIZE, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
619-
ftp_scratch_buffer = heap_caps_malloc(FTP_MAX_PARAM_SIZE, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
620-
ftp_cmd_buffer = heap_caps_malloc(FTP_MAX_PARAM_SIZE + FTP_CMD_SIZE_MAX, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
617+
ftp_data.dBuffer = malloc(FTP_BUFFER_SIZE);
618+
ftp_path = malloc(FTP_MAX_PARAM_SIZE);
619+
ftp_scratch_buffer = malloc(FTP_MAX_PARAM_SIZE);
620+
ftp_cmd_buffer = malloc(FTP_MAX_PARAM_SIZE + FTP_CMD_SIZE_MAX);
621621
SOCKETFIFO_Init (&ftp_socketfifo, (void *)ftp_fifoelements, FTP_SOCKETFIFO_ELEMENTS_MAX);
622622
ftp_data.c_sd = -1;
623623
ftp_data.d_sd = -1;

esp32/lte/lteppp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ void lteppp_init(void) {
159159

160160
lteppp_connstatus = LTE_PPP_IDLE;
161161
#ifdef LTE_DEBUG_BUFF
162-
lteppp_log.log = heap_caps_malloc(LTE_LOG_BUFF_SIZE, MALLOC_CAP_SPIRAM);
162+
lteppp_log.log = malloc(LTE_LOG_BUFF_SIZE);
163163
#endif
164164
}
165165

esp32/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ void app_main(void) {
149149
micropy_lpwan_dio_pin_num = 23;
150150
micropy_lpwan_dio_pin = &pin_GPIO23;
151151

152-
mpTaskStack = heap_caps_malloc(MICROPY_TASK_STACK_SIZE_PSRAM, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
152+
mpTaskStack = malloc(MICROPY_TASK_STACK_SIZE_PSRAM);
153153

154154
// create the MicroPython task
155155
mpTaskHandle =
@@ -172,7 +172,7 @@ void app_main(void) {
172172
micropy_lpwan_dio_pin_num = 23;
173173
micropy_lpwan_dio_pin = &pin_GPIO23;
174174

175-
mpTaskStack = heap_caps_malloc(MICROPY_TASK_STACK_SIZE, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
175+
mpTaskStack = malloc(MICROPY_TASK_STACK_SIZE);
176176

177177
// create the MicroPython task
178178
mpTaskHandle =

esp32/mods/modbt.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ static void remove_all_bonded_devices(void)
500500
{
501501
int dev_num = esp_ble_get_bond_device_num();
502502

503-
esp_ble_bond_dev_t *dev_list = heap_caps_malloc(sizeof(esp_ble_bond_dev_t) * dev_num, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
503+
esp_ble_bond_dev_t *dev_list = malloc(sizeof(esp_ble_bond_dev_t) * dev_num);
504504
esp_ble_get_bond_device_list(&dev_num, dev_list);
505505
for (int i = 0; i < dev_num; i++) {
506506
esp_ble_remove_bond_device(dev_list[i].bd_addr);
@@ -801,8 +801,8 @@ STATIC void gatts_char_callback_handler(void *arg) {
801801
tuple[1] = mp_const_none;
802802
if(((char_cbk_arg_t*)arg)->data_length > 0) {
803803
tuple[1] = mp_obj_new_bytes(((char_cbk_arg_t*)arg)->data, ((char_cbk_arg_t*)arg)->data_length);
804-
heap_caps_free(((char_cbk_arg_t*)arg)->data);
805-
heap_caps_free((char_cbk_arg_t*)arg);
804+
free(((char_cbk_arg_t*)arg)->data);
805+
free((char_cbk_arg_t*)arg);
806806
}
807807

808808
mp_obj_t r_value = mp_call_function_2(chr->handler, chr->handler_arg, mp_obj_new_tuple(2, tuple));
@@ -865,7 +865,7 @@ static void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_
865865
char_obj->read_request = true;
866866
char_obj->trans_id = p->read.trans_id;
867867

868-
char_cbk_arg_t *cbk_arg = heap_caps_malloc(sizeof(char_cbk_arg_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
868+
char_cbk_arg_t *cbk_arg = malloc(sizeof(char_cbk_arg_t));
869869

870870
cbk_arg->chr = char_obj;
871871
cbk_arg->event = MOD_BT_GATTS_READ_EVT;
@@ -900,12 +900,12 @@ static void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_
900900
char_obj->events |= MOD_BT_GATTS_WRITE_EVT;
901901
if (char_obj->trigger & MOD_BT_GATTS_WRITE_EVT) {
902902

903-
char_cbk_arg_t *cbk_arg = heap_caps_malloc(sizeof(char_cbk_arg_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
903+
char_cbk_arg_t *cbk_arg = malloc(sizeof(char_cbk_arg_t));
904904

905905
cbk_arg->chr = char_obj;
906906
cbk_arg->event = MOD_BT_GATTS_WRITE_EVT;
907907
cbk_arg->data_length = write_len;
908-
cbk_arg->data = heap_caps_malloc(cbk_arg->data_length, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
908+
cbk_arg->data = malloc(cbk_arg->data_length);
909909
memcpy(cbk_arg->data, p->write.value, cbk_arg->data_length);
910910

911911
mp_irq_queue_interrupt_non_ISR(gatts_char_callback_handler, cbk_arg);
@@ -918,7 +918,7 @@ static void gatts_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_
918918
char_obj->events |= MOD_BT_GATTS_SUBSCRIBE_EVT;
919919
if (char_obj->trigger & MOD_BT_GATTS_SUBSCRIBE_EVT) {
920920

921-
char_cbk_arg_t *cbk_arg = heap_caps_malloc(sizeof(char_cbk_arg_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
921+
char_cbk_arg_t *cbk_arg = malloc(sizeof(char_cbk_arg_t));
922922

923923
cbk_arg->chr = char_obj;
924924
cbk_arg->event = MOD_BT_GATTS_SUBSCRIBE_EVT;
@@ -2344,7 +2344,7 @@ STATIC mp_obj_t bt_srv_characteristics(mp_obj_t self_in) {
23442344
&attr_count);
23452345

23462346
if (attr_count > 0) {
2347-
esp_gattc_char_elem_t *char_elems = (esp_gattc_char_elem_t *)heap_caps_malloc(sizeof(esp_gattc_char_elem_t) * attr_count, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
2347+
esp_gattc_char_elem_t *char_elems = (esp_gattc_char_elem_t *)malloc(sizeof(esp_gattc_char_elem_t) * attr_count);
23482348
if (!char_elems) {
23492349
mp_raise_OSError(MP_ENOMEM);
23502350
} else {
@@ -2585,7 +2585,7 @@ STATIC mp_obj_t bt_char_callback(mp_uint_t n_args, const mp_obj_t *pos_args, mp_
25852585
self->characteristic.char_handle,
25862586
&attr_count);
25872587
if (attr_count > 0) {
2588-
esp_gattc_descr_elem_t *descr_elems = (esp_gattc_descr_elem_t *)heap_caps_malloc(sizeof(esp_gattc_descr_elem_t) * attr_count, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
2588+
esp_gattc_descr_elem_t *descr_elems = (esp_gattc_descr_elem_t *)malloc(sizeof(esp_gattc_descr_elem_t) * attr_count);
25892589
if (!descr_elems) {
25902590
mp_raise_OSError(MP_ENOMEM);
25912591
} else {

esp32/mods/moduqueue.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ STATIC mp_obj_t mod_uqueue_queue(mp_uint_t n_args, const mp_obj_t *pos_args, mp_
4545
mp_obj_queue_t *queue = m_new_obj_with_finaliser(mp_obj_queue_t);
4646

4747
// allocate the queue storage and the queue buffer
48-
queue->buffer = heap_caps_malloc(sizeof(StaticQueue_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
48+
queue->buffer = malloc(sizeof(StaticQueue_t));
4949
if (NULL == queue->buffer) {
5050
nlr_raise(mp_obj_new_exception_msg(&mp_type_MemoryError, "no memory available to create the queue"));
5151
}

esp32/mptask.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,12 @@ void TASK_Micropython (void *pvParameters) {
174174

175175
if (esp32_get_chip_rev() > 0) {
176176
gc_pool_size = GC_POOL_SIZE_BYTES_PSRAM;
177-
gc_pool_upy = heap_caps_malloc(GC_POOL_SIZE_BYTES_PSRAM, MALLOC_CAP_SPIRAM);
178177
} else {
179178
gc_pool_size = GC_POOL_SIZE_BYTES;
180-
gc_pool_upy = heap_caps_malloc(GC_POOL_SIZE_BYTES, MALLOC_CAP_INTERNAL);
181179
}
182180

181+
gc_pool_upy = malloc(gc_pool_size);
182+
183183
if (NULL == gc_pool_upy) {
184184
printf("GC pool malloc failed!\n");
185185
for ( ; ; );

esp32/mpthreadport.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,15 @@ void mp_thread_create_ex(void *(*entry)(void*), void *arg, size_t *stack_size, i
171171
// allocate TCB, stack and linked-list node (must be outside thread_mutex lock)
172172
if (mp_chip_revision > 0) {
173173
// for revision 1 devices we allocate from the internal memory of the malloc heap
174-
tcb = heap_caps_malloc(sizeof(StaticTask_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
174+
tcb = malloc(sizeof(StaticTask_t));
175175
if (!tcb) {
176176
goto memory_error;
177177
}
178-
stack = heap_caps_malloc(*stack_size, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
178+
stack = malloc(*stack_size);
179179
if (!stack) {
180180
goto memory_error;
181181
}
182-
th = heap_caps_malloc(sizeof(thread_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
182+
th = malloc(sizeof(thread_t));
183183
if (!th) {
184184
goto memory_error;
185185
}

esp32/telnet/telnet.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ static void telnet_reset_buffer (void);
154154
******************************************************************************/
155155
void telnet_init (void) {
156156
// allocate memory for the receive buffer (from the RTOS heap)
157-
telnet_data.rxBuffer = heap_caps_malloc(TELNET_RX_BUFFER_SIZE, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
157+
telnet_data.rxBuffer = malloc(TELNET_RX_BUFFER_SIZE);
158158
telnet_data.state = E_TELNET_STE_DISABLED;
159159
}
160160

0 commit comments

Comments
 (0)