Implements buffer.h functions (except low-layer functions)