rename .c to .cpp

This commit is contained in:
Staars 2022-03-27 17:57:35 +02:00
parent 3ed44ce0dc
commit b8fd073467
2 changed files with 100 additions and 0 deletions

View File

@ -0,0 +1,47 @@
/*
* 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>
//Tasmota Patch
extern void *special_malloc(uint32_t size);
extern void *special_calloc(size_t num, size_t size);
extern "C" {
void * hap_platform_memory_malloc(size_t size)
{
return special_malloc((uint32_t)size);
// return malloc(size);
}
void * hap_platform_memory_calloc(size_t count, size_t size)
{
return special_calloc(count,size);
// return calloc(count, size);
}
void hap_platform_memory_free(void *ptr)
{
free(ptr);
}
} //extern "C"

View File

@ -0,0 +1,53 @@
/*
* 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"
//Tasmota Patch
extern void *special_malloc(uint32_t size);
extern void *special_calloc(size_t num, size_t size);
extern "C" {
IRAM_ATTR void *nimble_platform_mem_malloc(size_t size)
{
return special_malloc((uint32_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)
{
return special_calloc(n,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);
}
} //extern "C"
#endif