I'm using the latest stable_19.1.x branch.
my code looks like:
Code: Select all
#define ALLOC_SIZE 256
#define MB_BUFFER_SIZE 8
typedef struct {
uint16_t size;
uint8_t buf[ALLOC_SIZE - 2];
} uart_msg_t;
static memory_heap_t heap_reader;
static uart_msg_t heap_reader_buffer[MB_BUFFER_SIZE];
static THD_FUNCTION(uart_reader, arg) {
(void)arg;
static uart_msg_t *uart_msg, *uart_msg_new;
chHeapObjectInit(&heap_reader, heap_reader_buffer,
sizeof(heap_reader_buffer));
uart_msg = chHeapAlloc(&heap_reader, sizeof(uart_msg_t));
while (true) {
do_stuff();
uart_msg = chHeapAlloc(&heap_reader, sizeof(uart_msg_t));
if (NULL == uart_msg)
// breakpoint
I always jump in the breakpoint after 7 allocations. I expect it should hit it after 8 allocs.
Any hints are welcome.