Variable-sized packet memory management for embedded applications