summaryrefslogtreecommitdiff
path: root/src/piece-table.h
diff options
context:
space:
mode:
authorEkaitz Zarraga <ekaitz@elenq.tech>2024-02-28 22:03:04 +0100
committerEkaitz Zarraga <ekaitz@elenq.tech>2024-02-28 22:08:20 +0100
commita1f6afa69bb25191d4b206e4ecba1557629330bc (patch)
tree3041324b6f0932ef036e9de230e965a4400f2b08 /src/piece-table.h
First commit with project structure
Diffstat (limited to 'src/piece-table.h')
-rw-r--r--src/piece-table.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/piece-table.h b/src/piece-table.h
new file mode 100644
index 0000000..94ab072
--- /dev/null
+++ b/src/piece-table.h
@@ -0,0 +1,32 @@
+#ifndef PIECE_TABLE_H
+#define PIECE_TABLE_H
+
+#include <malloc.h>
+#include <stddef.h>
+#include "buffer.h"
+
+struct piece {
+ char *start;
+ size_t length;
+ struct piece *next;
+ struct piece *prev;
+};
+
+typedef struct piece 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);
+
+void free_piece_list(piece *pt);
+
+#endif // PIECE_TABLE_H