aboutsummaryrefslogtreecommitdiff
path: root/structures/rope/rope.c
diff options
context:
space:
mode:
Diffstat (limited to 'structures/rope/rope.c')
-rw-r--r--structures/rope/rope.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/structures/rope/rope.c b/structures/rope/rope.c
index e1ae4a9..f3828df 100644
--- a/structures/rope/rope.c
+++ b/structures/rope/rope.c
@@ -28,6 +28,18 @@ rope* rope_new()
return tmp;
}
+size_t rope_len(root)
+rope *root;
+{
+ if (!root)
+ return 0;
+
+ if (root->str)
+ return strlen(root->str);
+
+ return rope_len(root->left) + rope_len(root->right);
+}
+
rope* str_to_rope(str)
char *str;
{