From f6d06421090f88094aba76b72b04d614f54efafa Mon Sep 17 00:00:00 2001 From: jacqueline Date: Tue, 26 Sep 2023 11:23:53 +1000 Subject: Prepare for PMR with a memory_resource that understands heap_caps_malloc --- src/util/allocator.cpp | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 src/util/allocator.cpp (limited to 'src/util/allocator.cpp') diff --git a/src/util/allocator.cpp b/src/util/allocator.cpp deleted file mode 100644 index d505ab3e..00000000 --- a/src/util/allocator.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2023 jacqueline - * - * SPDX-License-Identifier: GPL-3.0-only - */ - -#include - -#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 > 256) { - 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); -} \ No newline at end of file -- cgit v1.2.3