sm: add buffer management

Adds sm_buffer_t which manages the allocation of space in the buffer.
The init call taks the total length and the minimum allocation length.
A message length cannot be longer than 64 * min_len.