code reduction
This commit is contained in:
parent
8106dc4683
commit
6201f8006e
2 changed files with 3 additions and 14 deletions
14
memory.cpp
14
memory.cpp
|
@ -16,30 +16,22 @@ memory::memory(const uint32_t size): size(size)
|
|||
|
||||
if (size > 12 * 8192 && psramFound()) {
|
||||
Serial.println(F("Using PSRAM"));
|
||||
is_psram = true;
|
||||
|
||||
m = reinterpret_cast<uint8_t *>(ps_malloc(size));
|
||||
|
||||
reset();
|
||||
}
|
||||
else {
|
||||
m = new uint8_t[size]();
|
||||
m = reinterpret_cast<uint8_t *>(calloc(1, size));
|
||||
}
|
||||
#else
|
||||
m = new uint8_t[size]();
|
||||
m = reinterpret_cast<uint8_t *>(calloc(1, size));
|
||||
#endif
|
||||
}
|
||||
|
||||
memory::~memory()
|
||||
{
|
||||
#if defined(ESP32)
|
||||
if (is_psram)
|
||||
free(m);
|
||||
else
|
||||
delete [] m;
|
||||
#else
|
||||
delete [] m;
|
||||
#endif
|
||||
free(m);
|
||||
}
|
||||
|
||||
void memory::reset()
|
||||
|
|
3
memory.h
3
memory.h
|
@ -13,9 +13,6 @@ class memory
|
|||
private:
|
||||
const uint32_t size { 0 };
|
||||
uint8_t *m { nullptr };
|
||||
#ifdef ESP32
|
||||
bool is_psram { false };
|
||||
#endif
|
||||
|
||||
public:
|
||||
memory(const uint32_t size);
|
||||
|
|
Loading…
Add table
Reference in a new issue