diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-09-26 21:46:05 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-09-26 21:46:05 +1000 |
| commit | ce57b236c4b5fde21791fe6fa8a8a39cdfac78b4 (patch) | |
| tree | 2765b42f19591f08038a03728e7c434d6c2b13d8 /src/memory | |
| parent | 252f685ef1502016ed00be4eeaa4a217386fbce0 (diff) | |
| download | tangara-fw-ce57b236c4b5fde21791fe6fa8a8a39cdfac78b4.tar.gz | |
Move every alloc over 256 bytes into PSRAM
Diffstat (limited to 'src/memory')
| -rw-r--r-- | src/memory/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/memory/allocator.cpp | 29 |
2 files changed, 1 insertions, 30 deletions
diff --git a/src/memory/CMakeLists.txt b/src/memory/CMakeLists.txt index bd162e18..beee7399 100644 --- a/src/memory/CMakeLists.txt +++ b/src/memory/CMakeLists.txt @@ -3,7 +3,7 @@ # SPDX-License-Identifier: GPL-3.0-only idf_component_register( - SRCS "memory_resource.cpp" "allocator.cpp" + SRCS "memory_resource.cpp" INCLUDE_DIRS "include" REQUIRES "esp_psram") target_compile_options(${COMPONENT_LIB} PRIVATE ${EXTRA_WARNINGS}) diff --git a/src/memory/allocator.cpp b/src/memory/allocator.cpp deleted file mode 100644 index aaee08f8..00000000 --- a/src/memory/allocator.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2023 jacqueline <me@jacqueline.id.au> - * - * SPDX-License-Identifier: GPL-3.0-only - */ - -#include <cstdint> - -#include "esp_heap_caps.h" - -void* operator new[](std::size_t sz) { - if (sz == 0) { - ++sz; // avoid std::malloc(0) which may return nullptr on success - } - - if (sz > 512) { - return heap_caps_malloc(sz, MALLOC_CAP_SPIRAM); - } - - return heap_caps_malloc(sz, MALLOC_CAP_DEFAULT); -} - -void operator delete[](void* ptr) noexcept { - heap_caps_free(ptr); -} - -void operator delete[](void* ptr, std::size_t size) noexcept { - heap_caps_free(ptr); -} |
