blob: b65da15026131f13a5b9cb46b37f8e28877c6c2e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#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;
void 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, size_t pos, char *val, size_t len);
void delete_piece_table(piece_table *pt, size_t pos, size_t len);
void print_piece_table(piece_table *pt);
#endif // PIECE_TABLE_H
|