mirror of
https://github.com/Fishwaldo/bl_mcu_sdk.git
synced 2025-07-23 21:29:17 +00:00
32 lines
577 B
C
32 lines
577 B
C
#include "bflb_platform.h"
|
|
#include <stddef.h>
|
|
|
|
static uint8_t *mallocBuf = NULL;
|
|
static uint32_t malloced = 0;
|
|
static uint32_t bufsize = 0;
|
|
|
|
void simple_malloc_init(uint8_t *buf, uint32_t len)
|
|
{
|
|
mallocBuf = buf;
|
|
malloced = 0;
|
|
bufsize = len;
|
|
}
|
|
void *simple_malloc(uint32_t size)
|
|
{
|
|
uint8_t *p;
|
|
MSG_DBG("Simple Malloc %d\r\n", size);
|
|
|
|
if (malloced + size < bufsize) {
|
|
p = mallocBuf + malloced;
|
|
malloced += size;
|
|
return p;
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
void simple_free(void *p)
|
|
{
|
|
MSG_DBG("Simple Free %08x\r\n", p);
|
|
return;
|
|
}
|