fragpool  20170302
Variable-sized packet memory management for embedded applications
Fragpool: Variable-sized packet memory management for embedded applications

Fragpool is a memory management infrastructure designed to support stream-to-packet layer interfaces in memory constrained devices.

The use case is an embedded system which passes data between a stream-oriented interface such as a UART and a packet-oriented interface such as HDLC. The expectation is that the final length of a packet is not known at the point where stream reception starts. Consequently a system is obliged to allocate a large buffer. Once the packet is complete the data must be passed to another layer, and the unused space should be reclaimed and made available for new packets that are received while previous packets are being processed.

There are only a few functions, accessed by including <fragpool/fragpool.h>:

The memory available for allocation and the degree of fragmentation supported are fixed for the life of the pool, normally at the time the application is compiled. Allocation will adjust caller-provided sizes to maintain pool-defined alignment constraints.

All fragpool routines are non-blocking and are intended to be callable from hard interrupt context. Protection against re-entrancy must be supplied by the caller.