Skip to content

Commit 76003d7

Browse files
Increased the size of the mem buffer & the new allocator can be used (with a small buffer) when the legacy one is being used
1 parent aedc35f commit 76003d7

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/mem.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
#include "mem_alloc.h"
1414
#include "os_print.h"
1515

16-
#define SIZE_MEM_BUFFER 10240
16+
#define SIZE_MEM_BUFFER_MAIN 10240
17+
#define SIZE_MEM_BUFFER_ALT 2048
18+
#define SIZE_MEM_BUFFER (SIZE_MEM_BUFFER_MAIN + SIZE_MEM_BUFFER_ALT)
1719

1820
static uint8_t mem_buffer[SIZE_MEM_BUFFER] __attribute__((aligned(8)));
1921
static uint16_t mem_legacy_idx;
@@ -51,6 +53,8 @@ void app_mem_free_impl(void *ptr, const char *file, int line) {
5153
*/
5254
void mem_legacy_init(void) {
5355
mem_legacy_idx = 0;
56+
// initialize the new allocator to still be able to use it, just in case
57+
mem_ctx = mem_init(mem_buffer + SIZE_MEM_BUFFER_MAIN, SIZE_MEM_BUFFER_ALT);
5458
}
5559

5660
/**
@@ -77,7 +81,7 @@ void *mem_legacy_alloc(size_t size) {
7781
return NULL;
7882
}
7983
// Buffer exceeded
80-
if (new_idx > sizeof(mem_buffer)) {
84+
if (new_idx > SIZE_MEM_BUFFER_MAIN) {
8185
PRINTF("Error: mem_alloc(%u) failed!\n", size);
8286
return NULL;
8387
}

0 commit comments

Comments
 (0)