Add strbuf definition and functions
Move write_repeat* functions to be strbuf functions
Calculate table size
Finish internal table-writing functions