code reduction

This commit is contained in:
folkert van heusden 2024-04-27 21:50:15 +02:00
parent 8106dc4683
commit 6201f8006e
Signed by untrusted user who does not match committer: folkert
GPG key ID: 6B6455EDFEED3BD1
2 changed files with 3 additions and 14 deletions

View file

@ -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
}
void memory::reset()

View file

@ -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);