feat(openthread): support alloc nat64 session from psram

This commit is contained in:
zwx
2024-09-09 20:38:29 +08:00
committed by Xu Si Yu
parent aa67538038
commit d7f69d03c0
4 changed files with 55 additions and 7 deletions

View File

@@ -0,0 +1,21 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "esp_heap_caps.h"
#include <utility>
#include "common/new.hpp"
template <typename T, typename... Args>
inline T *New(uint32_t alloc_caps, Args &&...args)
{
void *p = heap_caps_calloc(1, sizeof(T), alloc_caps);
if (p != nullptr) {
return new (p) T(std::forward<Args>(args)...);
}
return nullptr;
}