diff options
| author | WormHeamer | 2025-12-27 23:26:28 -0500 |
|---|---|---|
| committer | WormHeamer | 2025-12-27 23:26:28 -0500 |
| commit | bf4535008a78ed84fe3e76a9ae262646b9a5f150 (patch) | |
| tree | 86a0a199e15634c9fe6682de9e08593ef9237687 /main.c | |
basic piece table implementation
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -0,0 +1,27 @@ +#include <stdio.h> +#include <stdint.h> +#include <stddef.h> + +#include <fcntl.h> +#include <unistd.h> +#include <sys/stat.h> + +#define ARENA_IMPL + +#include "wrmr.h" +#include "arena.h" +#include "txt.h" + +int main(void) { + Arena a = arena_init(1L << 20); + Txt txt = { 0 }; + txt_open(&txt, "test.txt"); + txt_insert(&txt, txt.len, "wheeee", 6); + txt_delete(&txt, txt.len, 6); + for (u32 i = 0; i < txt.ptbl.n; i++) { + TxtPiece *p = &txt.ptbl.v[i]; + printf("%u. %.*s\n", i, (int)p->n, txt.buf[p->buf].s + p->ofs); + } + arena_free(&a); + return 0; +} |
