This repository has been archived on 2023-07-17. You can view files and clone it, but cannot push or open issues or pull requests.
bl_mcu_sdk/components/xz/xz_port.c

31 lines
556 B
C
Raw Normal View History

2021-06-04 17:51:55 +08:00
#include "bflb_platform.h"
2021-06-20 12:25:46 +08:00
static uint8_t *mallocBuf = NULL;
static uint32_t malloced = 0;
static uint32_t bufsize = 0;
2021-06-04 17:51:55 +08:00
void simple_malloc_init(uint8_t *buf, uint32_t len)
{
2021-06-20 12:25:46 +08:00
mallocBuf = buf;
malloced = 0;
bufsize = len;
2021-06-04 17:51:55 +08:00
}
2021-06-20 12:25:46 +08:00
void *simple_malloc(uint32_t size)
{
2021-06-04 17:51:55 +08:00
uint8_t *p;
2021-06-20 12:25:46 +08:00
MSG_DBG("Simple Malloc %d\r\n", size);
if (malloced + size < bufsize) {
p = mallocBuf + malloced;
malloced += size;
return p;
2021-06-04 17:51:55 +08:00
}
2021-06-20 12:25:46 +08:00
2021-06-04 17:51:55 +08:00
return NULL;
}
void simple_free(void *p)
{
2021-06-20 12:25:46 +08:00
MSG_DBG("Simple Free %08x\r\n", p);
return;
2021-06-04 17:51:55 +08:00
}