use an fbuf instead of managing the buffer memory ourselves

the overhead is minimum and code is less and simpler