Initial commit: TXW82x FPV v2.7.0.7-42229 SDK + project sources
This commit is contained in:
180
sdk/lib/heap/alloc.c
Normal file
180
sdk/lib/heap/alloc.c
Normal file
@@ -0,0 +1,180 @@
|
||||
#include "sys_config.h"
|
||||
#include "typesdef.h"
|
||||
#include "osal/string.h"
|
||||
#include "lib/heap/sysheap.h"
|
||||
#include "lib/common/rbuffer.h"
|
||||
|
||||
/***********************************************************************
|
||||
MEM_RECLIST - 内存 申请/释放 操作流水记录。
|
||||
使用方法:
|
||||
1. 添加宏定义:
|
||||
#define MEM_RECLIST_CNT 256 - 表示记录最后256条内存访问记录
|
||||
|
||||
2. 在需要检测的 申请/释放 API里面添加:mem_alloc_rec 和 mem_free_rec
|
||||
-申请内存成功时调用:mem_alloc_rec
|
||||
-释放内存时调用:mem_free_rec
|
||||
__malloc和__free函数有示例代码。
|
||||
|
||||
3. 执行 mem_reclist_dump API 打印被记录的内存访问信息
|
||||
SDK在检测到内存越界或内存信息损坏时,也会自动执行 mem_reclist_dump
|
||||
***********************************************************************/
|
||||
//#define MEM_RECLIST_CNT 256
|
||||
#ifdef MEM_RECLIST_CNT
|
||||
struct mem_reclist {
|
||||
void *addr;
|
||||
void *lr;
|
||||
uint64 tick;
|
||||
};
|
||||
static uint16 g_mfreelist_pos, g_malloclist_pos;
|
||||
static struct mem_reclist g_mfreelist[MEM_RECLIST_CNT];
|
||||
static struct mem_reclist g_malloclist[MEM_RECLIST_CNT];
|
||||
#endif
|
||||
|
||||
void mem_free_rec(void *addr, void *lr)
|
||||
{
|
||||
#ifdef MEM_RECLIST_CNT
|
||||
uint32 flag = disable_irq();
|
||||
g_mfreelist[g_mfreelist_pos].addr = addr;
|
||||
g_mfreelist[g_mfreelist_pos].lr = lr;
|
||||
g_mfreelist[g_mfreelist_pos].tick = os_jiffies();
|
||||
g_mfreelist_pos++;
|
||||
if (g_mfreelist_pos >= MEM_RECLIST_CNT) {
|
||||
g_mfreelist_pos = 0;
|
||||
}
|
||||
enable_irq(flag);
|
||||
#endif
|
||||
}
|
||||
|
||||
void mem_alloc_rec(void *addr, void *lr)
|
||||
{
|
||||
#ifdef MEM_RECLIST_CNT
|
||||
uint32 flag = disable_irq();
|
||||
g_malloclist[g_malloclist_pos].addr = addr;
|
||||
g_malloclist[g_malloclist_pos].lr = lr;
|
||||
g_malloclist[g_malloclist_pos].tick = os_jiffies();
|
||||
g_malloclist_pos++;
|
||||
if (g_malloclist_pos >= MEM_RECLIST_CNT) {
|
||||
g_malloclist_pos = 0;
|
||||
}
|
||||
enable_irq(flag);
|
||||
#endif
|
||||
}
|
||||
|
||||
void mem_reclist_dump(void)
|
||||
{
|
||||
#ifdef MEM_RECLIST_CNT
|
||||
uint32 i = 0;
|
||||
uint32 flag = disable_irq();
|
||||
os_printf("------------------------------------------\r\n");
|
||||
os_printf("MEM ALLOC Reclist:\r\n");
|
||||
for (i = 0; i < MEM_RECLIST_CNT; i++) {
|
||||
if (g_malloclist[i].addr) {
|
||||
os_printf(" MEM:%p, LR:%p, tick:%lld\r\n", g_malloclist[i].addr, g_malloclist[i].lr, g_malloclist[i].tick);
|
||||
}
|
||||
}
|
||||
os_printf("MEM FREE Reclist:\r\n");
|
||||
for (i = 0; i < MEM_RECLIST_CNT; i++) {
|
||||
if (g_mfreelist[i].addr) {
|
||||
os_printf(" MEM:%p, LR:%p, tick:%lld\r\n", g_mfreelist[i].addr, g_mfreelist[i].lr, g_mfreelist[i].tick);
|
||||
}
|
||||
}
|
||||
os_printf("------------------------------------------\r\n");
|
||||
enable_irq(flag);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef MPOOL_ALLOC
|
||||
void *__malloc(struct sys_heap *heap, int size, void *lr)
|
||||
{
|
||||
void *ptr = sysheap_alloc(heap, size, lr, 0);
|
||||
if (ptr) {
|
||||
//mem_alloc_rec(ptr, lr);
|
||||
ASSERT((uint32)ptr == ALIGN((uint32)ptr, heap->pool.align));
|
||||
} else {
|
||||
os_printf(KERN_WARNING"%s: malloc fail, size=%d [LR:%p]\tremain size:%d\r\n", heap->name, size, lr,sysheap_freesize(heap));
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void *__zalloc(struct sys_heap *heap, int size, void *lr)
|
||||
{
|
||||
void *ptr = __malloc(heap, size, lr);
|
||||
if (ptr) {
|
||||
os_memset(ptr, 0, size);
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void *__realloc(struct sys_heap *heap, void *ptr, int size, void *lr)
|
||||
{
|
||||
void *nptr = __malloc(heap, size, lr);
|
||||
if (nptr) {
|
||||
if (ptr) {
|
||||
os_memcpy(nptr, ptr, size);
|
||||
__free(heap, ptr, lr);
|
||||
}
|
||||
}else{
|
||||
os_printf(KERN_WARNING"Realloc failed, be careful of memory leaks! (size=%d, LR:%p)\r\n", size, lr);
|
||||
}
|
||||
return nptr;
|
||||
}
|
||||
void __free(struct sys_heap *heap, void *ptr, void *lr)
|
||||
{
|
||||
if (ptr) {
|
||||
//mem_free_rec(ptr, lr);
|
||||
ASSERT((uint32)ptr == ALIGN((uint32)ptr, heap->pool.align));
|
||||
if (sysheap_free(heap, ptr)) {
|
||||
os_printf(KERN_WARNING"%s: free error, ptr=%p, [LR:%p]\r\n", heap->name, ptr, lr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void *__malloc_t(struct sys_heap *heap, int size, const char *func, int line)
|
||||
{
|
||||
void *ptr = sysheap_alloc(heap, size, func, line);
|
||||
if (ptr) {
|
||||
//mem_alloc_rec(ptr, (void *)func);
|
||||
ASSERT((uint32)ptr == ALIGN((uint32)ptr, heap->pool.align));
|
||||
} else {
|
||||
os_printf(KERN_WARNING"%s: malloc fail, size=%d [%s:%d]\tremain size:%d\r\n", heap->name, size, func, line, sysheap_freesize(heap));
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void *__zalloc_t(struct sys_heap *heap, int size, const char *func, int line)
|
||||
{
|
||||
void *ptr = __malloc_t(heap, size, func, line);
|
||||
if (ptr) {
|
||||
os_memset(ptr, 0, size);
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void *__realloc_t(struct sys_heap *heap, void *ptr, int size, const char *func, int line)
|
||||
{
|
||||
void *nptr = __malloc_t(heap, size, func, line);
|
||||
if (nptr) {
|
||||
if (ptr) {
|
||||
os_memcpy(nptr, ptr, size);
|
||||
__free_t(heap, ptr, func, line);
|
||||
}
|
||||
}else{
|
||||
os_printf(KERN_WARNING"Realloc failed, be careful of memory leaks! (size=%d, %s:%d)\r\n", size, func, line);
|
||||
}
|
||||
|
||||
return nptr;
|
||||
}
|
||||
|
||||
void __free_t(struct sys_heap *heap, void *ptr, const char *func, int line)
|
||||
{
|
||||
if (ptr) {
|
||||
//mem_free_rec(ptr, (void *)func);
|
||||
ASSERT((uint32)ptr == ALIGN((uint32)ptr, heap->pool.align));
|
||||
if (sysheap_free(heap, ptr)) {
|
||||
os_printf(KERN_WARNING"%s: free error, ptr=%p, [%s:%d]\r\n", heap->name, ptr, func, line);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
82
sdk/lib/heap/av_heap.c
Normal file
82
sdk/lib/heap/av_heap.c
Normal file
@@ -0,0 +1,82 @@
|
||||
#include "sys_config.h"
|
||||
#include "typesdef.h"
|
||||
#include "osal/string.h"
|
||||
#include "lib/heap/sysheap.h"
|
||||
#include "lib/common/rbuffer.h"
|
||||
|
||||
#if defined(MPOOL_ALLOC) && defined(AV_HEAP)
|
||||
__bobj struct sys_av_heap av_heap;
|
||||
|
||||
__init void av_heap_init(void *start_addr,uint32_t size,uint32_t flags)
|
||||
{
|
||||
//uint32 flags = SYSHEAP_FLAGS_MEM_ALIGN_32;
|
||||
//flags |= SYSHEAP_FLAGS_MEM_LEAK_TRACE | SYSHEAP_FLAGS_MEM_OVERFLOW_CHECK;
|
||||
if(size)
|
||||
{
|
||||
av_heap.name = "av_sram";
|
||||
av_heap.ops = &mmpool1_ops;
|
||||
sysheap_init(&av_heap, (void *)start_addr, size, flags);
|
||||
}
|
||||
}
|
||||
|
||||
//打印当前heap的状态,参数为buf以及buf的空间(world为单位)
|
||||
void av_heap_status(uint32_t *buf,uint32_t size)
|
||||
{
|
||||
if(size)
|
||||
{
|
||||
sysheap_status(&av_heap, buf, size, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void *av_malloc(int size)
|
||||
{
|
||||
return __malloc((struct sys_heap *)&av_heap, size, RETURN_ADDR());
|
||||
}
|
||||
|
||||
void av_free(void *ptr)
|
||||
{
|
||||
__free((struct sys_heap *)&av_heap, ptr, RETURN_ADDR());
|
||||
}
|
||||
|
||||
void *av_zalloc(int size)
|
||||
{
|
||||
return __zalloc((struct sys_heap *)&av_heap, size, RETURN_ADDR());
|
||||
}
|
||||
|
||||
void *av_calloc(int nmemb, int size)
|
||||
{
|
||||
return __zalloc((struct sys_heap *)&av_heap, nmemb * size, RETURN_ADDR());
|
||||
}
|
||||
|
||||
void *av_realloc(void *ptr, int size)
|
||||
{
|
||||
return __realloc((struct sys_heap *)&av_heap, ptr, size, RETURN_ADDR());
|
||||
}
|
||||
|
||||
void *av_malloc_t(int size, const char *func, int line)
|
||||
{
|
||||
return __malloc_t((struct sys_heap *)&av_heap, size, func, line);
|
||||
}
|
||||
|
||||
void av_free_t(void *ptr, const char *func, int line)
|
||||
{
|
||||
return __free_t((struct sys_heap *)&av_heap, ptr, func, line);
|
||||
}
|
||||
|
||||
void *av_zalloc_t(int size, const char *func, int line)
|
||||
{
|
||||
return __zalloc_t((struct sys_heap *)&av_heap, size, func, line);
|
||||
}
|
||||
|
||||
void *av_calloc_t(int nmemb, int size, const char *func, int line)
|
||||
{
|
||||
return __zalloc_t((struct sys_heap *)&av_heap, nmemb * size, func, line);
|
||||
}
|
||||
|
||||
void *av_realloc_t(void *ptr, int size, const char *func, int line)
|
||||
{
|
||||
return __realloc_t((struct sys_heap *)&av_heap, ptr, size, func, line);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
30
sdk/lib/heap/av_heap.h
Normal file
30
sdk/lib/heap/av_heap.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef _AV_HEAP
|
||||
#define _AV_HEAP
|
||||
#include "sys_config.h"
|
||||
#include "typesdef.h"
|
||||
#include "osal/string.h"
|
||||
#if defined(MPOOL_ALLOC) && defined(AV_HEAP)
|
||||
extern struct sys_av_heap av_heap;
|
||||
void av_heap_init(uint8_t *start_addr,uint32_t size,uint32_t flags);
|
||||
void av_heap_status(uint32_t *buf,uint32_t size);
|
||||
void *av_malloc(int size);
|
||||
void av_free(void *ptr);
|
||||
void *av_zalloc(int size);
|
||||
void *av_calloc(int nmemb, int size);
|
||||
void *av_realloc(void *ptr, int size);
|
||||
void *av_malloc_t(int size, const char *func, int line);
|
||||
void av_free_t(void *ptr, const char *func, int line);
|
||||
void *av_zalloc_t(int size, const char *func, int line);
|
||||
void *av_calloc_t(int nmemb, int size, const char *func, int line);
|
||||
void *av_realloc_t(void *ptr, int size, const char *func, int line);
|
||||
#else
|
||||
|
||||
#define av_malloc _os_malloc
|
||||
#define av_free _os_free
|
||||
#define av_zalloc _os_zalloc
|
||||
#define av_calloc _os_calloc
|
||||
#define av_realloc _os_realloc
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
81
sdk/lib/heap/av_psram_heap.c
Normal file
81
sdk/lib/heap/av_psram_heap.c
Normal file
@@ -0,0 +1,81 @@
|
||||
#include "sys_config.h"
|
||||
#include "typesdef.h"
|
||||
#include "osal/string.h"
|
||||
#include "lib/heap/sysheap.h"
|
||||
#include "lib/common/rbuffer.h"
|
||||
|
||||
#if defined(MPOOL_ALLOC) && defined(AV_PSRAM_HEAP) && defined(PSRAM_HEAP)
|
||||
__bobj struct sys_psramheap av_psram_heap;
|
||||
__init void av_psram_heap_init(void *start_addr,uint32_t size,uint32_t flags)
|
||||
{
|
||||
//uint32 flags = SYSHEAP_FLAGS_MEM_ALIGN_32;
|
||||
//flags |= SYSHEAP_FLAGS_MEM_LEAK_TRACE | SYSHEAP_FLAGS_MEM_OVERFLOW_CHECK;
|
||||
if(size)
|
||||
{
|
||||
av_psram_heap.name = "av_psram";
|
||||
av_psram_heap.ops = &mmpool1_ops;
|
||||
sysheap_init(&av_psram_heap, (void *)start_addr, size, flags);
|
||||
}
|
||||
}
|
||||
|
||||
//打印当前heap的状态,参数为buf以及buf的空间(world为单位)
|
||||
void av_psram_heap_status(uint32_t *buf,uint32_t size)
|
||||
{
|
||||
if(size)
|
||||
{
|
||||
sysheap_status(&av_psram_heap, buf, size, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void *av_psram_malloc(int size)
|
||||
{
|
||||
return __malloc((struct sys_heap *)&av_psram_heap, size, RETURN_ADDR());
|
||||
}
|
||||
|
||||
void av_psram_free(void *ptr)
|
||||
{
|
||||
__free((struct sys_heap *)&av_psram_heap, ptr, RETURN_ADDR());
|
||||
}
|
||||
|
||||
void *av_psram_zalloc(int size)
|
||||
{
|
||||
return __zalloc((struct sys_heap *)&av_psram_heap, size, RETURN_ADDR());
|
||||
}
|
||||
|
||||
void *av_psram_calloc(int nmemb, int size)
|
||||
{
|
||||
return __zalloc((struct sys_heap *)&av_psram_heap, nmemb * size, RETURN_ADDR());
|
||||
}
|
||||
|
||||
void *av_psram_realloc(void *ptr, int size)
|
||||
{
|
||||
return __realloc((struct sys_heap *)&av_psram_heap, ptr, size, RETURN_ADDR());
|
||||
}
|
||||
|
||||
void *av_psram_malloc_t(int size, const char *func, int line)
|
||||
{
|
||||
return __malloc_t((struct sys_heap *)&av_psram_heap, size, func, line);
|
||||
}
|
||||
|
||||
void av_psram_free_t(void *ptr, const char *func, int line)
|
||||
{
|
||||
return __free_t((struct sys_heap *)&av_psram_heap, ptr, func, line);
|
||||
}
|
||||
|
||||
void *av_psram_zalloc_t(int size, const char *func, int line)
|
||||
{
|
||||
return __zalloc_t((struct sys_heap *)&av_psram_heap, size, func, line);
|
||||
}
|
||||
|
||||
void *av_psram_calloc_t(int nmemb, int size, const char *func, int line)
|
||||
{
|
||||
return __zalloc_t((struct sys_heap *)&av_psram_heap, nmemb * size, func, line);
|
||||
}
|
||||
|
||||
void *av_psram_realloc_t(void *ptr, int size, const char *func, int line)
|
||||
{
|
||||
return __realloc_t((struct sys_heap *)&av_psram_heap, ptr, size, func, line);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
30
sdk/lib/heap/av_psram_heap.h
Normal file
30
sdk/lib/heap/av_psram_heap.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef _AV_PSRAM_HEAP
|
||||
#define _AV_PSRAM_HEAP
|
||||
#include "sys_config.h"
|
||||
#include "typesdef.h"
|
||||
#include "osal/string.h"
|
||||
#if defined(MPOOL_ALLOC) && defined(AV_PSRAM_HEAP) && defined(PSRAM_HEAP)
|
||||
extern struct sys_psramheap av_psram_heap;
|
||||
void av_psram_heap_init(uint8_t *start_addr,uint32_t size,uint32_t flags);
|
||||
void av_psram_heap_status(uint32_t *buf,uint32_t size);
|
||||
void *av_psram_malloc(int size);
|
||||
void av_psram_free(void *ptr);
|
||||
void *av_psram_zalloc(int size);
|
||||
void *av_psram_calloc(int nmemb, int size);
|
||||
void *av_psram_realloc(void *ptr, int size);
|
||||
void *av_psram_malloc_t(int size, const char *func, int line);
|
||||
void av_psram_free_t(void *ptr, const char *func, int line);
|
||||
void *av_psram_zalloc_t(int size, const char *func, int line);
|
||||
void *av_psram_calloc_t(int nmemb, int size, const char *func, int line);
|
||||
void *av_psram_realloc_t(void *ptr, int size, const char *func, int line);
|
||||
#else
|
||||
|
||||
#define av_psram_malloc _os_malloc_psram
|
||||
#define av_psram_free _os_free_psram
|
||||
#define av_psram_zalloc _os_zalloc_psram
|
||||
#define av_psram_calloc _os_calloc_psram
|
||||
#define av_psram_realloc _os_realloc_psram
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
75
sdk/lib/heap/psram_heap.c
Normal file
75
sdk/lib/heap/psram_heap.c
Normal file
@@ -0,0 +1,75 @@
|
||||
#include "sys_config.h"
|
||||
#include "typesdef.h"
|
||||
#include "osal/string.h"
|
||||
#include "lib/heap/sysheap.h"
|
||||
#include "lib/common/rbuffer.h"
|
||||
|
||||
#if defined(MPOOL_ALLOC) && defined(PSRAM_HEAP)
|
||||
__bobj struct sys_psramheap psram_heap;
|
||||
|
||||
void *_os_malloc_psram(int size)
|
||||
{
|
||||
return __malloc((struct sys_heap *)&psram_heap, size, RETURN_ADDR());
|
||||
}
|
||||
|
||||
void _os_free_psram(void *ptr)
|
||||
{
|
||||
__free((struct sys_heap *)&psram_heap, ptr, RETURN_ADDR());
|
||||
}
|
||||
|
||||
void *_os_zalloc_psram(int size)
|
||||
{
|
||||
return __zalloc((struct sys_heap *)&psram_heap, size, RETURN_ADDR());
|
||||
}
|
||||
|
||||
void *_os_calloc_psram(int nmemb, int size)
|
||||
{
|
||||
return __zalloc((struct sys_heap *)&psram_heap, nmemb * size, RETURN_ADDR());
|
||||
}
|
||||
|
||||
void *_os_realloc_psram(void *ptr, int size)
|
||||
{
|
||||
return __realloc((struct sys_heap *)&psram_heap, ptr, size, RETURN_ADDR());
|
||||
}
|
||||
|
||||
void *_os_malloc_psram_t(int size, const char *func, int line)
|
||||
{
|
||||
return __malloc_t((struct sys_heap *)&psram_heap, size, func, line);
|
||||
}
|
||||
|
||||
void _os_free_psram_t(void *ptr, const char *func, int line)
|
||||
{
|
||||
return __free_t((struct sys_heap *)&psram_heap, ptr, func, line);
|
||||
}
|
||||
|
||||
void *_os_zalloc_psram_t(int size, const char *func, int line)
|
||||
{
|
||||
return __zalloc_t((struct sys_heap *)&psram_heap, size, func, line);
|
||||
}
|
||||
|
||||
void *_os_calloc_psram_t(int nmemb, int size, const char *func, int line)
|
||||
{
|
||||
return __zalloc_t((struct sys_heap *)&psram_heap, nmemb * size, func, line);
|
||||
}
|
||||
|
||||
void *_os_realloc_psram_t(void *ptr, int size, const char *func, int line)
|
||||
{
|
||||
return __realloc_t((struct sys_heap *)&psram_heap, ptr, size, func, line);
|
||||
}
|
||||
|
||||
void *malloc_psram(int size) __alias(_os_malloc_psram);
|
||||
void free_psram(void *ptr) __alias(_os_free_psram);
|
||||
void *zalloc_psram(int size) __alias(_os_zalloc_psram);
|
||||
void *calloc_psram(int nmemb, int size) __alias(_os_calloc_psram);
|
||||
void *realloc_psram(void *ptr, int size) __alias(_os_realloc_psram);
|
||||
|
||||
#ifdef MALLOC_IN_PSRAM
|
||||
void *malloc(size_t size) __alias(_os_malloc_psram);
|
||||
void free(void *ptr) __alias(_os_free_psram);
|
||||
void *zalloc(size_t size) __alias(_os_zalloc_psram);
|
||||
void *calloc(size_t nmemb, size_t size) __alias(_os_calloc_psram);
|
||||
void *realloc(void *ptr, size_t size) __alias(_os_realloc_psram);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
100
sdk/lib/heap/sram_heap.c
Normal file
100
sdk/lib/heap/sram_heap.c
Normal file
@@ -0,0 +1,100 @@
|
||||
#include "sys_config.h"
|
||||
#include "typesdef.h"
|
||||
#include "osal/string.h"
|
||||
#include "lib/heap/sysheap.h"
|
||||
#include "lib/common/rbuffer.h"
|
||||
|
||||
#ifdef MPOOL_ALLOC
|
||||
__bobj struct sys_sramheap sram_heap;
|
||||
|
||||
void *_os_malloc(int size)
|
||||
{
|
||||
return __malloc((struct sys_heap *)&sram_heap, size, RETURN_ADDR());
|
||||
}
|
||||
|
||||
void _os_free(void *ptr)
|
||||
{
|
||||
__free((struct sys_heap *)&sram_heap, ptr, RETURN_ADDR());
|
||||
}
|
||||
|
||||
void *_os_zalloc(int size)
|
||||
{
|
||||
return __zalloc((struct sys_heap *)&sram_heap, size, RETURN_ADDR());
|
||||
}
|
||||
|
||||
void *_os_calloc(size_t nmemb, size_t size)
|
||||
{
|
||||
return __zalloc((struct sys_heap *)&sram_heap, nmemb * size, RETURN_ADDR());
|
||||
}
|
||||
|
||||
void *_os_realloc(void *ptr, int size)
|
||||
{
|
||||
return __realloc((struct sys_heap *)&sram_heap, ptr, size, RETURN_ADDR());
|
||||
}
|
||||
|
||||
void *_os_malloc_t(int size, const char *func, int line)
|
||||
{
|
||||
return __malloc_t((struct sys_heap *)&sram_heap, size, func, line);
|
||||
}
|
||||
|
||||
void _os_free_t(void *ptr, const char *func, int line)
|
||||
{
|
||||
return __free_t((struct sys_heap *)&sram_heap, ptr, func, line);
|
||||
}
|
||||
|
||||
void *_os_zalloc_t(int size, const char *func, int line)
|
||||
{
|
||||
return __zalloc_t((struct sys_heap *)&sram_heap, size, func, line);
|
||||
}
|
||||
|
||||
void *_os_calloc_t(int nmemb, int size, const char *func, int line)
|
||||
{
|
||||
return __zalloc_t((struct sys_heap *)&sram_heap, nmemb * size, func, line);
|
||||
}
|
||||
|
||||
void *_os_realloc_t(void *ptr, int size, const char *func, int line)
|
||||
{
|
||||
return __realloc_t((struct sys_heap *)&sram_heap, ptr, size, func, line);
|
||||
}
|
||||
|
||||
#ifndef MALLOC_IN_PSRAM
|
||||
void *malloc(size_t size) __alias(_os_malloc);
|
||||
void free(void *ptr) __alias(_os_free);
|
||||
void *zalloc(size_t size) __alias(_os_zalloc);
|
||||
void *calloc(size_t nmemb, size_t size) __alias(_os_calloc);
|
||||
void *realloc(void *ptr, size_t size) __alias(_os_realloc);
|
||||
#endif
|
||||
|
||||
#ifndef PSRAM_HEAP
|
||||
void *malloc_psram(int size) __alias(_os_malloc);
|
||||
void free_psram(void *ptr) __alias(_os_free);
|
||||
void *zalloc_psram(int size) __alias(_os_zalloc);
|
||||
void *calloc_psram(int nmemb, int size) __alias(_os_calloc);
|
||||
void *realloc_psram(void *ptr, int size) __alias(_os_realloc);
|
||||
void *_os_malloc_psram(int size) __alias(_os_malloc);
|
||||
void _os_free_psram(void *ptr) __alias(_os_free);
|
||||
void *_os_zalloc_psram(int size) __alias(_os_zalloc);
|
||||
void *_os_calloc_psram(int nmemb, int size) __alias(_os_calloc);
|
||||
void *_os_realloc_psram(void *ptr, int size) __alias(_os_realloc);
|
||||
void *_os_malloc_psram_t(int size, const char *func, int line) __alias(_os_malloc_t);
|
||||
void _os_free_psram_t(void *ptr, const char *func, int line) __alias(_os_free_t);
|
||||
void *_os_zalloc_psram_t(int size, const char *func, int line) __alias(_os_zalloc_t);
|
||||
void *_os_calloc_psram_t(int nmemb, int size, const char *func, int line) __alias(_os_calloc_t);
|
||||
void *_os_realloc_psram_t(void *ptr, int size, const char *func, int line) __alias(_os_realloc_t);
|
||||
#endif
|
||||
|
||||
#ifndef AV_HEAP
|
||||
void *_av_malloc(int size) __alias(_os_malloc);
|
||||
void _av_free(void *ptr) __alias(_os_free);
|
||||
void *_av_zalloc(int size) __alias(_os_zalloc);
|
||||
void *_av_calloc(int nmemb, int size) __alias(_os_calloc);
|
||||
void *_av_realloc(void *ptr, int size) __alias(_os_realloc);
|
||||
void *_av_malloc_t(int size, const char *func, int line) __alias(_os_malloc_t);
|
||||
void _av_free_t(void *ptr, const char *func, int line) __alias(_os_free_t);
|
||||
void *_av_zalloc_t(int size, const char *func, int line) __alias(_os_zalloc_t);
|
||||
void *_av_calloc_t(int nmemb, int size, const char *func, int line) __alias(_os_calloc_t);
|
||||
void *_av_realloc_t(void *ptr, int size, const char *func, int line) __alias(_os_realloc_t);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user