From 6201f8006e3c6a027fd2ca0a27a0b02f19e4e048 Mon Sep 17 00:00:00 2001 From: folkert van heusden Date: Sat, 27 Apr 2024 21:50:15 +0200 Subject: [PATCH] code reduction --- memory.cpp | 14 +++----------- memory.h | 3 --- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/memory.cpp b/memory.cpp index 64fa1ba..ab3d526 100644 --- a/memory.cpp +++ b/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(ps_malloc(size)); reset(); } else { - m = new uint8_t[size](); + m = reinterpret_cast(calloc(1, size)); } #else - m = new uint8_t[size](); + m = reinterpret_cast(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() diff --git a/memory.h b/memory.h index 5bf11e6..7a43089 100644 --- a/memory.h +++ b/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);