summaryrefslogtreecommitdiff
path: root/lib/bt/common/osi/allocator.c
diff options
context:
space:
mode:
authorcooljqln <cooljqln@noreply.codeberg.org>2025-08-04 03:39:45 +0200
committercooljqln <cooljqln@noreply.codeberg.org>2025-08-04 03:39:45 +0200
commitfd064b996a432074b3e5c18b6a8c5439a372f281 (patch)
tree4e3b2880e11f3169000d4273323399677af8c05f /lib/bt/common/osi/allocator.c
parentdf8fc4104e5ed884f3b52257558191955375d1e7 (diff)
parentf4eea3a18add40b84ea2494970ef5945c755f578 (diff)
downloadtangara-fw-fd064b996a432074b3e5c18b6a8c5439a372f281.tar.gz
Merge pull request 'Update esp-idf to the v5.5' (#418) from jqln/idfv5.5 into main
Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/418
Diffstat (limited to 'lib/bt/common/osi/allocator.c')
-rw-r--r--lib/bt/common/osi/allocator.c48
1 files changed, 18 insertions, 30 deletions
diff --git a/lib/bt/common/osi/allocator.c b/lib/bt/common/osi/allocator.c
index 4d10e10f..86fb705b 100644
--- a/lib/bt/common/osi/allocator.c
+++ b/lib/bt/common/osi/allocator.c
@@ -213,42 +213,30 @@ char *osi_strdup(const char *str)
void *osi_malloc_func(size_t size)
{
-#if HEAP_MEMORY_DEBUG
- void *p;
-#if HEAP_ALLOCATION_FROM_SPIRAM_FIRST
- p = heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL);
-#else
- p = malloc(size);
-#endif /* #if HEAP_ALLOCATION_FROM_SPIRAM_FIRST */
- osi_mem_dbg_record(p, size, __func__, __LINE__);
+ void *p = osi_malloc_base(size);
+
+ if (size != 0 && p == NULL) {
+ OSI_TRACE_ERROR("malloc failed (caller=%p size=%u)\n", __builtin_return_address(0), size);
+#if HEAP_ALLOCATION_FAILS_ABORT
+ assert(0);
+#endif
+ }
+
return p;
-#else
-#if HEAP_ALLOCATION_FROM_SPIRAM_FIRST
- return heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL);
-#else
- return malloc(size);
-#endif /* #if HEAP_ALLOCATION_FROM_SPIRAM_FIRST */
-#endif /* #if HEAP_MEMORY_DEBUG */
}
void *osi_calloc_func(size_t size)
{
-#if HEAP_MEMORY_DEBUG
- void *p;
-#if HEAP_ALLOCATION_FROM_SPIRAM_FIRST
- p = heap_caps_calloc_prefer(1, size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL);
-#else
- p = calloc(1, size);
-#endif /* #if HEAP_ALLOCATION_FROM_SPIRAM_FIRST */
- osi_mem_dbg_record(p, size, __func__, __LINE__);
+ void *p = osi_calloc_base(size);
+
+ if (size != 0 && p == NULL) {
+ OSI_TRACE_ERROR("calloc failed (caller=%p size=%u)\n", __builtin_return_address(0), size);
+#if HEAP_ALLOCATION_FAILS_ABORT
+ assert(0);
+#endif
+ }
+
return p;
-#else
-#if HEAP_ALLOCATION_FROM_SPIRAM_FIRST
- return heap_caps_calloc_prefer(1, size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL);
-#else
- return calloc(1, size);
-#endif /* #if HEAP_ALLOCATION_FROM_SPIRAM_FIRST */
-#endif /* #if HEAP_MEMORY_DEBUG */
}
void osi_free_func(void *ptr)