Eliminated use of exceptions in PSRAM.h and added -fno-exceptions
Added build_opt.h which include -fno-exceptions compiler instructions. Seems to save about 29K of flash in compiled code (compiling for ESP32)
This commit is contained in:
parent
1863cc4309
commit
8775a2df85
11
src/PSRAM.h
11
src/PSRAM.h
|
|
@ -45,11 +45,14 @@ template <class T>
|
|||
struct Mallocator {
|
||||
typedef T value_type;
|
||||
Mallocator() = default;
|
||||
template <class U> constexpr Mallocator(const Mallocator<U>&) noexcept {}
|
||||
template <class U> constexpr Mallocator(const Mallocator<U>&) {}
|
||||
[[nodiscard]] T* allocate(std::size_t n) {
|
||||
if(n > std::size_t(-1) / sizeof(T)) throw std::bad_alloc();
|
||||
if(auto p = static_cast<T*>(HS_MALLOC(n*sizeof(T)))) return p;
|
||||
throw std::bad_alloc();
|
||||
auto p = static_cast<T*>(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); }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
-fno-exceptions
|
||||
Loading…
Reference in New Issue