Skip to content

Commit 48fbb1d

Browse files
committed
code formatting, removed now unused function declaration
1 parent 516aa62 commit 48fbb1d

File tree

3 files changed

+23
-26
lines changed

3 files changed

+23
-26
lines changed

wled00/FX_fcn.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ bool Segment::allocateData(size_t len) {
148148
if (len == 0) return false; // nothing to do
149149
if (data && _dataLen >= len) { // already allocated enough (reduce fragmentation)
150150
if (call == 0) {
151-
if(_dataLen < FAIR_DATA_PER_SEG) { // segment data is small
151+
if (_dataLen < FAIR_DATA_PER_SEG) { // segment data is small
152152
//DEBUG_PRINTF_P(PSTR("-- Clearing data (%d): %p\n"), len, this);
153153
memset(data, 0, len); // erase buffer if called during effect initialisation
154154
return true; // no need to reallocate
@@ -160,7 +160,7 @@ bool Segment::allocateData(size_t len) {
160160
//DEBUG_PRINTF_P(PSTR("-- Allocating data (%d): %p\n"), len, this);
161161
// limit to MAX_SEGMENT_DATA if there is no PSRAM, otherwise prefer functionality over speed
162162
#if defined(ARDUINO_ARCH_ESP32)
163-
if(!(psramFound() && psramSafe))
163+
if (!(psramFound() && psramSafe))
164164
#endif
165165
{
166166
if (Segment::getUsedSegmentData() + len - _dataLen > MAX_SEGMENT_DATA) {
@@ -214,7 +214,7 @@ void Segment::resetIfRequired() {
214214
if (!reset || !isActive()) return;
215215
//DEBUG_PRINTF_P(PSTR("-- Segment reset: %p\n"), this);
216216
if (data && _dataLen > 0) {
217-
if(_dataLen > FAIR_DATA_PER_SEG) deallocateData(); // do not keep large allocations
217+
if (_dataLen > FAIR_DATA_PER_SEG) deallocateData(); // do not keep large allocations
218218
else memset(data, 0, _dataLen); // can prevent heap fragmentation
219219
DEBUG_PRINTF_P(PSTR("-- Segment %p reset, data cleared\n"), this);
220220
}

wled00/fcn_declare.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,6 @@ inline uint8_t hw_random8(uint32_t upperlimit) { return (hw_random8() * upperlim
551551
inline uint8_t hw_random8(uint32_t lowerlimit, uint32_t upperlimit) { uint32_t range = upperlimit - lowerlimit; return lowerlimit + hw_random8(range); }; // input range 0-255
552552

553553
// memory allocation wrappers
554-
#ifdef CONFIG_IDF_TARGET_ESP32
555-
void *pixelbuffer_malloc(size_t size, bool enforcePSRAM = false); // prefer IRAM for pixel buffers if possible
556-
#endif
557554
#if !defined(ESP8266) && !defined(CONFIG_IDF_TARGET_ESP32C3)
558555
extern "C" {
559556
void *p_malloc(size_t); // prefer PSRAM over DRAM
@@ -589,12 +586,12 @@ inline size_t getContiguousFreeHeap() { return heap_caps_get_largest_free_block(
589586
inline size_t getFreeHeapSize() { return ESP.getFreeHeap(); } // returns free heap
590587
inline size_t getContiguousFreeHeap() { return ESP.getMaxFreeBlockSize(); } // returns largest contiguous free block
591588
#endif
592-
#define BFRALLOC_NOBYTEACCESS (1 << 0) // ESP32 has 32bit accessible DRAM (usually ~50kB free) that must not be byte-accessed
593-
#define BFRALLOC_PREFER_DRAM (1 << 1) // prefer DRAM over PSRAM
594-
#define BFRALLOC_ENFORCE_DRAM (1 << 2) // use DRAM only, no PSRAM
595-
#define BFRALLOC_PREFER_PSRAM (1 << 3) // prefer PSRAM over DRAM
596-
#define BFRALLOC_ENFORCE_PSRAM (1 << 4) // use PSRAM if available, otherwise fall back to DRAM
597-
#define BFRALLOC_CLEAR (1 << 5) // clear allocated buffer after allocation
589+
#define BFRALLOC_NOBYTEACCESS (1 << 0) // ESP32 has 32bit accessible DRAM (usually ~50kB free) that must not be byte-accessed
590+
#define BFRALLOC_PREFER_DRAM (1 << 1) // prefer DRAM over PSRAM
591+
#define BFRALLOC_ENFORCE_DRAM (1 << 2) // use DRAM only, no PSRAM
592+
#define BFRALLOC_PREFER_PSRAM (1 << 3) // prefer PSRAM over DRAM
593+
#define BFRALLOC_ENFORCE_PSRAM (1 << 4) // use PSRAM if available, otherwise fall back to DRAM
594+
#define BFRALLOC_CLEAR (1 << 5) // clear allocated buffer after allocation
598595
void *allocate_buffer(size_t size, uint32_t type);
599596

600597
// RAII guard class for the JSON Buffer lock

wled00/util.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)