diff options
-rw-r--r-- | structures/rope/rope.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/structures/rope/rope.c b/structures/rope/rope.c index aed104b..1f0a389 100644 --- a/structures/rope/rope.c +++ b/structures/rope/rope.c @@ -82,11 +82,23 @@ rope *root; return 0; if (root->str) - return strlen(root->str); + return root->len; return rope_len(root->left) + rope_len(root->right); } +size_t rope_relen(root) +rope *root; +{ + if (!root) + return 0; + + if (root->str) + return root->len; + + return root->len = rope_relen(root->left) + rope_len(root->right); +} + rope* str_to_rope(str) char *str; { |