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 {
|
struct Mallocator {
|
||||||
typedef T value_type;
|
typedef T value_type;
|
||||||
Mallocator() = default;
|
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) {
|
[[nodiscard]] T* allocate(std::size_t n) {
|
||||||
if(n > std::size_t(-1) / sizeof(T)) throw std::bad_alloc();
|
auto p = static_cast<T*>(HS_MALLOC(n*sizeof(T)));
|
||||||
if(auto p = static_cast<T*>(HS_MALLOC(n*sizeof(T)))) return p;
|
if(p==NULL){
|
||||||
throw std::bad_alloc();
|
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); }
|
void deallocate(T* p, std::size_t) noexcept { std::free(p); }
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
-fno-exceptions
|
||||||
Loading…
Reference in New Issue