From 4db1b6bc1dc6b880014ea0546ba30c73fea54643 Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Sun, 10 Aug 2025 01:43:41 +0200 Subject: Restart! --- src/piece-table.h | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) (limited to 'src/piece-table.h') diff --git a/src/piece-table.h b/src/piece-table.h index b65da15..59972ee 100644 --- a/src/piece-table.h +++ b/src/piece-table.h @@ -1,34 +1,35 @@ +/* parc + * Copyright (C) 2025 Ekaitz Zarraga + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #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; +typedef struct _piece_table piece_table; -void init_piece_table(piece_table *pt, char *orig); -void free_piece_table(piece_table *pt); +piece_table *piece_table_create (); +void piece_table_destroy (piece_table * piece_table); -char index_piece_table(piece_table *pt, size_t pos); -void insert_piece_table(piece_table *pt, size_t pos, char *val, size_t len); -void delete_piece_table(piece_table *pt, size_t pos, size_t len); +char piece_table_index (piece_table *pt, size_t pos); +void piece_table_insert (piece_table *pt, size_t pos, char *in, size_t len); +void piece_table_delete (piece_table *pt, size_t start, size_t end); -void print_piece_table(piece_table *pt); +void piece_table_print (piece_table *pt); +char *piece_table_to_string (piece_table *pt); -#endif // PIECE_TABLE_H +#endif -- cgit v1.2.3