mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-18 00:06:29 +00:00
use special_malloc for external libs
This commit is contained in:
parent
f9305f6de8
commit
3ed44ce0dc
@ -1,39 +0,0 @@
|
|||||||
/*
|
|
||||||
* ESPRESSIF MIT License
|
|
||||||
*
|
|
||||||
* Copyright (c) 2019 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
|
|
||||||
*
|
|
||||||
* Permission is hereby granted for use on ESPRESSIF SYSTEMS products only, in which case,
|
|
||||||
* it is free of charge, to any person obtaining a copy of this software and associated
|
|
||||||
* documentation files (the "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished
|
|
||||||
* to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in all copies or
|
|
||||||
* substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
||||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
||||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
void * hap_platform_memory_malloc(size_t size)
|
|
||||||
{
|
|
||||||
return malloc(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void * hap_platform_memory_calloc(size_t count, size_t size)
|
|
||||||
{
|
|
||||||
return calloc(count, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void hap_platform_memory_free(void *ptr)
|
|
||||||
{
|
|
||||||
free(ptr);
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef ESP_PLATFORM
|
|
||||||
|
|
||||||
#include "esp_attr.h"
|
|
||||||
#include "esp_heap_caps.h"
|
|
||||||
#include "nimconfig.h"
|
|
||||||
#include "../include/esp_nimble_mem.h"
|
|
||||||
|
|
||||||
IRAM_ATTR void *nimble_platform_mem_malloc(size_t size)
|
|
||||||
{
|
|
||||||
#ifdef CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_INTERNAL
|
|
||||||
return heap_caps_malloc(size, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
|
||||||
#elif CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_EXTERNAL
|
|
||||||
return heap_caps_malloc(size, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT);
|
|
||||||
#elif CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_IRAM_8BIT
|
|
||||||
return heap_caps_malloc_prefer(size, 2, MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
|
||||||
#else
|
|
||||||
return malloc(size);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
IRAM_ATTR void *nimble_platform_mem_calloc(size_t n, size_t size)
|
|
||||||
{
|
|
||||||
#ifdef CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_INTERNAL
|
|
||||||
return heap_caps_calloc(n, size, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
|
||||||
#elif CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_EXTERNAL
|
|
||||||
return heap_caps_calloc(n, size, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT);
|
|
||||||
#elif CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_IRAM_8BIT
|
|
||||||
return heap_caps_calloc_prefer(n, size, 2, MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
|
||||||
#else
|
|
||||||
return calloc(n, size);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
IRAM_ATTR void nimble_platform_mem_free(void *ptr)
|
|
||||||
{
|
|
||||||
heap_caps_free(ptr);
|
|
||||||
}
|
|
||||||
#endif
|
|
Loading…
x
Reference in New Issue
Block a user