diff --git a/src/PSRAM.h b/src/PSRAM.h index dd9e03a..d5b0cb6 100644 --- a/src/PSRAM.h +++ b/src/PSRAM.h @@ -45,11 +45,14 @@ template struct Mallocator { typedef T value_type; Mallocator() = default; - template constexpr Mallocator(const Mallocator&) noexcept {} + template constexpr Mallocator(const Mallocator&) {} [[nodiscard]] T* allocate(std::size_t n) { - if(n > std::size_t(-1) / sizeof(T)) throw std::bad_alloc(); - if(auto p = static_cast(HS_MALLOC(n*sizeof(T)))) return p; - throw std::bad_alloc(); + auto p = static_cast(HS_MALLOC(n*sizeof(T))); + if(p==NULL){ + Serial.printf("\n\n*** FATAL ERROR: Requested allocation of %d bytes failed. Program Halting.\n\n",n*sizeof(T)); + while(1); + } + return p; } void deallocate(T* p, std::size_t) noexcept { std::free(p); } }; diff --git a/src/build_opt.h b/src/build_opt.h new file mode 100644 index 0000000..f7f5b39 --- /dev/null +++ b/src/build_opt.h @@ -0,0 +1 @@ +-fno-exceptions