diff --git a/inc/pbuf.h b/inc/pbuf.h index 423d1d9..07abb5b 100644 --- a/inc/pbuf.h +++ b/inc/pbuf.h @@ -53,13 +53,13 @@ #define PBUF_DECLARE_POOL(pool_name, pbuf_count, pbuf_size) \ -static uint8_t pool_name##_payload_memory[(pbuf_count) * (pbuf_size)] __attribute__((aligned(4))); \ +static uint8_t pool_name##_payload_memory[(pbuf_count) * (((pbuf_size) + 3) & ~3)] __attribute__((aligned(4))); \ static pbuf_t pool_name##_memory[pbuf_count]; \ pbuf_pool_t pool_name #define STATIC_PBUF_DECLARE_POOL(pool_name, pbuf_count, pbuf_size) \ -static uint8_t pool_name##_payload_memory[(pbuf_count) * (pbuf_size)] __attribute__((aligned(4))); \ +static uint8_t pool_name##_payload_memory[(pbuf_count) * (((pbuf_size) + 3) & ~3)] __attribute__((aligned(4))); \ static pbuf_t pool_name##_memory[pbuf_count]; \ static pbuf_pool_t pool_name diff --git a/src/pbuf.c b/src/pbuf.c index 5fb380e..193ad01 100644 --- a/src/pbuf.c +++ b/src/pbuf.c @@ -8,6 +8,8 @@ assert(pbuf_memory); assert(pbuf_payload_memory); + pbuf_payload_capacity = (pbuf_payload_capacity + 3) & ~3; + pool->pbuf_memory = (pbuf_t*)pbuf_memory; pool->pbuf_count = pbuf_count;