From f0d3a27dd997f0746ed48da967771cee7dbebb48 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Thu, 12 Oct 2023 09:02:19 +1100 Subject: Ensure StaticTask_t allocs are internal --- src/tasks/tasks.hpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/tasks/tasks.hpp') diff --git a/src/tasks/tasks.hpp b/src/tasks/tasks.hpp index 1b6a108f..2f008120 100644 --- a/src/tasks/tasks.hpp +++ b/src/tasks/tasks.hpp @@ -12,6 +12,7 @@ #include #include +#include "esp_heap_caps.h" #include "freertos/FreeRTOS.h" #include "freertos/portmacro.h" #include "freertos/projdefs.h" @@ -54,7 +55,8 @@ auto PersistentMain(void* fn) -> void; template auto StartPersistent(const std::function& fn) -> void { - StaticTask_t* task_buffer = new StaticTask_t; + StaticTask_t* task_buffer = static_cast(heap_caps_malloc( + sizeof(StaticTask_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)); cpp::span stack = AllocateStack(); xTaskCreateStatic(&PersistentMain, Name().c_str(), stack.size(), new std::function(fn), Priority(), @@ -64,7 +66,8 @@ auto StartPersistent(const std::function& fn) -> void { template auto StartPersistent(BaseType_t core, const std::function& fn) -> void { - StaticTask_t* task_buffer = new StaticTask_t; + StaticTask_t* task_buffer = static_cast(heap_caps_malloc( + sizeof(StaticTask_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)); cpp::span stack = AllocateStack(); xTaskCreateStaticPinnedToCore(&PersistentMain, Name().c_str(), stack.size(), new std::function(fn), @@ -81,7 +84,7 @@ class Worker { StackType_t* stack_; QueueHandle_t queue_; std::atomic is_task_running_; - StaticTask_t task_buffer_; + StaticTask_t *task_buffer_; TaskHandle_t task_; struct WorkItem { -- cgit v1.2.3