summaryrefslogtreecommitdiff
path: root/src/piece-table.h
diff options
context:
space:
mode:
authorEkaitz Zarraga <ekaitz@elenq.tech>2025-08-10 01:43:41 +0200
committerEkaitz Zarraga <ekaitz@elenq.tech>2025-08-11 01:16:19 +0200
commit4db1b6bc1dc6b880014ea0546ba30c73fea54643 (patch)
tree9e93686df7db9765306c8749f8aa56f07fdeeb8f /src/piece-table.h
parent9de2985c2ddd2d98f8299d5ff8a5921ccea5769d (diff)
Restart!
Diffstat (limited to 'src/piece-table.h')
-rw-r--r--src/piece-table.h51
1 files changed, 26 insertions, 25 deletions
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 <ekaitz@elenq.tech>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
#ifndef PIECE_TABLE_H
#define PIECE_TABLE_H
-#include <malloc.h>
#include <stddef.h>
-#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