Taken from kugel's out-of-tree version:
https://github.com/kugel-/buflib
Needs some API adaptions. More test will follow.
Note: The expected output needs an update since
the in-tree version of buflib does buffer alignment
and also progressed a bit. Still the tests are a very good start.
Added Rockbox copyright header during import were needed.
Change-Id: Ib39ec4301285f1dd53059b7bed0c0d6646297dc5