#ifndef PIECE_TABLE_H #define PIECE_TABLE_H #include #include #include "buffer.h" typedef struct _piece { char *start; size_t length; struct _piece *next; struct _piece *prev; } piece; typedef struct { fixed_buffer orig; growable_buffer add; piece *sentinel; size_t length; piece *cached; size_t cached_offset; } piece_table; bool init_piece_table(piece_table *pt, char *orig); void free_piece_table(piece_table *pt); char index_piece_table(piece_table *pt, size_t pos); void insert_piece_table(piece_table *pt, char val, size_t pos); void delete_piece_table(piece_table *pt, size_t pos, size_t len); #endif // PIECE_TABLE_H