the code in question is c code that allocs a memory pool to be used for the purpose of a cross-tile messaging API developed by one of our ex devs. I do not run into the ET_LOAD_STORE issue on some xs2a applications (usually different hardware targets), but I am seeing it on one particular device. I am hoping for some insight on why this particular code may be triggering this error. It occurs in memoryPoolAllocate as outlined below.A memory operation was performed that was not properly aligned. This could be a
word load or word store to an address where the least significant log2 Bpw bits
were not zero, or access to a 16-bit number using LD16S or ST16 where the least
significant bit of the address was one.
Code: Select all
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "memorypool.h"
struct MemoryPool
{
struct MemoryPool* head;
};
void memoryPoolInit(struct MemoryPool* pool, uint32_t* memory, int count, int size)
{
memset (memory, 0, sizeof(memory[0]) * count * size);
pool->head = (struct MemoryPool*)memory;
pool->head->head = NULL;
for(int i = 1; i < count; i += 1)
{
struct MemoryPool* p = (struct MemoryPool*)(&memory[i * size]);
p->head = pool->head->head;
pool->head->head = p;
}
}
void* memoryPoolAllocate(struct MemoryPool* pool)
{
struct MemoryPool* p = pool->head;
if(p)
{
pool->head = p->head; //ET_LOAD_STORE happening here!
}
return p;
}
void memoryPoolFree(struct MemoryPool* pool, void* block)
{
struct MemoryPool* p = block;
p->head = pool->head;
pool->head = p;
}