From be0b9926ddcee4f6af1eef1091d48c919e611340 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Thu, 31 Dec 2020 03:18:52 -0500 Subject: Add base for rope structure --- structures/rope/rope.c | 29 +++++++++++++++++++++++++++++ structures/rope/rope.h | 8 ++++++++ 2 files changed, 37 insertions(+) create mode 100644 structures/rope/rope.c create mode 100644 structures/rope/rope.h 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 +#include +#include +#include +#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 -- cgit v1.1