replaced size_t with long in buf.c