Select one of the symbols to view example projects that use it.
 
Outline
#include "esp_attr.h"
#include "esp_heap_caps.h"
#include "sdkconfig.h"
#include "esp_log.h"
#include <assert.h>
log_count
bt_osi_mem_malloc(size_t)
bt_osi_mem_calloc(size_t, size_t)
bt_osi_mem_malloc_internal(size_t)
bt_osi_mem_calloc_internal(size_t, size_t)
bt_osi_mem_free(void *)
Files
loading (4/5)...
SourceVuESP-IDF Framework and ExamplesESP-IDFcomponents/bt/porting/mem/bt_osi_mem.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/* * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 *//* ... */ #include "esp_attr.h" #include "esp_heap_caps.h" #include "sdkconfig.h" #include "esp_log.h" #include <assert.h>5 includes static uint8_t log_count; IRAM_ATTR void *bt_osi_mem_malloc(size_t size) { void *mem = NULL; #ifdef CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_INTERNAL mem = heap_caps_malloc(size, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT); #elif CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_EXTERNAL mem = heap_caps_malloc(size, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT); #elif CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_IRAM_8BIT mem = heap_caps_malloc_prefer(size, 2, MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT); #else mem = malloc(size); #endif if (!mem) { log_count ++; if ((log_count % 100) == 0) { ESP_EARLY_LOGI("ESP_LOG_INFO","malloc failed (size %zu)",size); log_count = 0; }{...} assert(mem != NULL); }{...} return mem; }{ ... } IRAM_ATTR void *bt_osi_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 *bt_osi_mem_malloc_internal(size_t size) { return heap_caps_malloc(size, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT|MALLOC_CAP_DMA); }{ ... } IRAM_ATTR void *bt_osi_mem_calloc_internal(size_t n, size_t size) { return heap_caps_calloc(n, size, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT|MALLOC_CAP_DMA); }{ ... } IRAM_ATTR void bt_osi_mem_free(void *ptr) { heap_caps_free(ptr); }{ ... }
Details