aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTucker Evans <tucker@tuckerevans.com>2020-12-31 03:20:14 -0500
committerTucker Evans <tucker@tuckerevans.com>2020-12-31 03:20:14 -0500
commit435ab65d59f2a2eb1908a4b399049f6bfa0934e3 (patch)
tree4a45b493dd0f8cf56e379d589302d32e255aa034
parentbe0b9926ddcee4f6af1eef1091d48c919e611340 (diff)
Add func to embed a char* (str) into a rope
-rw-r--r--structures/rope/rope.c16
-rw-r--r--structures/rope/rope.h1
2 files changed, 17 insertions, 0 deletions
diff --git a/structures/rope/rope.c b/structures/rope/rope.c
index 9e0d551..e1ae4a9 100644
--- a/structures/rope/rope.c
+++ b/structures/rope/rope.c
@@ -27,3 +27,19 @@ rope* rope_new()
return tmp;
}
+
+rope* str_to_rope(str)
+char *str;
+{
+ rope *tmp;
+
+ if (!str)
+ return NULL;
+
+ tmp = rope_new();
+ tmp->len = strlen(str);
+ tmp->str = strdup(str);
+
+ return tmp;
+}
+
diff --git a/structures/rope/rope.h b/structures/rope/rope.h
index 4ffd726..80e60a3 100644
--- a/structures/rope/rope.h
+++ b/structures/rope/rope.h
@@ -4,5 +4,6 @@
typede struct rope_s rope;
rope* rope_new();
+rope* str_to_rope(char*);
#endif