Add callback memory callback functionality for buffers.

It will allow us to supply our own memory functions.