port of chainbuf.h -- fast chained buffers