buffer: size_t -> int