@@ -723,53 +723,53 @@ void *allocate_buffer(size_t size, uint32_t type) {
723723 #else
724724 #ifdef CONFIG_IDF_TARGET_ESP32
725725 // only classic ESP32 has this memory type. Using it frees up normal DRAM for other purposes
726- if (type & BFRALLOC_NOBYTEACCESS) {
726+ if (type & BFRALLOC_NOBYTEACCESS) {
727727 buffer = static_cast <uint32_t *>(heap_caps_malloc (size, MALLOC_CAP_INTERNAL | MALLOC_CAP_32BIT)); // try to allocate in 32bit DRAM region
728- if ((uintptr_t )buffer < SOC_DRAM_HIGH) {
728+ if ((uintptr_t )buffer < SOC_DRAM_HIGH) {
729729 // buffer did not fit into 32bit DRAM region (located at SOC_IRAM_LOW) and was allocated in 8bit DRAM memory or is nullptr
730730 // if PSRAM is available and a PSRAM type is set, free the memory and try again
731- if (psramSafe && psramFound () && (type & (BFRALLOC_PREFER_PSRAM | BFRALLOC_ENFORCE_PSRAM))) {
731+ if (psramSafe && psramFound () && (type & (BFRALLOC_PREFER_PSRAM | BFRALLOC_ENFORCE_PSRAM))) {
732732 free (buffer);
733733 buffer = nullptr ;
734734 }
735735 }
736- if (buffer)
736+ if (buffer)
737737 type = type & BFRALLOC_CLEAR; // we have a valid buffer, reset any additional flags except BFRALLOC_CLEAR
738738 }
739739 #endif
740- if (psramSafe && psramFound ()) {
741- if (type & BFRALLOC_PREFER_DRAM) {
740+ if (psramSafe && psramFound ()) {
741+ if (type & BFRALLOC_PREFER_DRAM) {
742742 buffer = d_malloc (size);
743743 }
744- else if (type & BFRALLOC_ENFORCE_DRAM) {
744+ else if (type & BFRALLOC_ENFORCE_DRAM) {
745745 buffer = heap_caps_malloc (size, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT); // use DRAM only
746746 }
747- else if (type & BFRALLOC_PREFER_PSRAM) {
747+ else if (type & BFRALLOC_PREFER_PSRAM) {
748748 buffer = p_malloc (size); // try to allocate in PSRAM
749749 }
750- else if (type & BFRALLOC_ENFORCE_PSRAM) {
750+ else if (type & BFRALLOC_ENFORCE_PSRAM) {
751751 buffer = heap_caps_malloc (size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT); // use PSRAM if available
752752 } else {
753753 buffer = p_malloc (size); // use PSRAM or DRAM depending on availability
754754 }
755755 }
756756 else {
757757 #ifdef CONFIG_IDF_TARGET_ESP32
758- if (!buffer)
759- buffer = d_malloc (size); // no PSRAM available, use DRAM if not already allocated above
758+ if (!buffer)
759+ buffer = d_malloc (size); // no PSRAM available, use DRAM if not already allocated above
760760 #else
761761 buffer = d_malloc (size); // no PSRAM available, use DRAM
762762 #endif
763763 }
764764 #endif
765- if (buffer) {
765+ if (buffer) {
766766 // check if there is enough heap left for the UI to work
767- if (getFreeHeapSize () < MIN_HEAP_SIZE)
767+ if (getFreeHeapSize () < MIN_HEAP_SIZE)
768768 {
769769 free (buffer); // free allocated buffer
770770 return nullptr ; // return nullptr to indicate failure
771771 }
772- if (type & BFRALLOC_CLEAR)
772+ if (type & BFRALLOC_CLEAR)
773773 memset (buffer, 0 , size); // clear allocated buffer
774774 }
775775 return buffer;
0 commit comments