diff options
author | Tucker Evans <tucker@tuckerevans.com> | 2020-12-31 03:18:52 -0500 |
---|---|---|
committer | Tucker Evans <tucker@tuckerevans.com> | 2020-12-31 03:18:52 -0500 |
commit | be0b9926ddcee4f6af1eef1091d48c919e611340 (patch) | |
tree | 148e289d0e01f5b71a0fa13e0feece0955af69ba | |
parent | 4e1c2be8b650a9ea13f56565deb407a8e9164d62 (diff) |
Add base for rope structure
-rw-r--r-- | structures/rope/rope.c | 29 | ||||
-rw-r--r-- | structures/rope/rope.h | 8 |
2 files changed, 37 insertions, 0 deletions
diff --git a/structures/rope/rope.c b/structures/rope/rope.c new file mode 100644 index 0000000..9e0d551 --- /dev/null +++ b/structures/rope/rope.c @@ -0,0 +1,29 @@ +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <assert.h> +#include "rope.h" + +struct rope_s { + size_t len; + char *str; + + struct rope_s *left, *right, *parent; +}; + + +rope* rope_new() +{ + rope *tmp; + + tmp = malloc(sizeof(rope)); + assert(tmp); + + tmp->len = 0; + tmp->str = NULL; + tmp->left = NULL; + tmp->right = NULL; + tmp->parent = NULL; + + return tmp; +} diff --git a/structures/rope/rope.h b/structures/rope/rope.h new file mode 100644 index 0000000..4ffd726 --- /dev/null +++ b/structures/rope/rope.h @@ -0,0 +1,8 @@ +#ifndef ROPE_H +#define ROPE_H + +typede struct rope_s rope; + +rope* rope_new(); + +#endif |