diff options
author | Tucker Evans <tucker@tuckerevans.com> | 2020-12-31 03:21:27 -0500 |
---|---|---|
committer | Tucker Evans <tucker@tuckerevans.com> | 2020-12-31 03:21:27 -0500 |
commit | a877aba402d5087d8fdb3a4e8ae7462656ca9589 (patch) | |
tree | b9b6ecfef1db0690b3a3c250fdf00aae8615fe48 /structures/rope/rope.c | |
parent | e2a99fae3709a5e0fdff92c2a787cde595bdffcc (diff) |
Add concat function for ropes
Diffstat (limited to 'structures/rope/rope.c')
-rw-r--r-- | structures/rope/rope.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/structures/rope/rope.c b/structures/rope/rope.c index f3828df..50c7fef 100644 --- a/structures/rope/rope.c +++ b/structures/rope/rope.c @@ -55,3 +55,20 @@ char *str; return tmp; } +rope* rope_concat(node1, node2) +rope *node1, *node2; +{ + rope *tmp; + + if (!node1 || !node2) + return node1 ? node1 : node2; + + tmp = rope_new(); + tmp->len = rope_len(node1); + tmp->left = node1; + tmp->right = node2; + node1->parent = tmp; + node2->parent = tmp; + + return tmp; +} |