From 54877babe8700bc39c7e2f8528e5146ed2fe6831 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Sun, 3 Jan 2021 23:19:26 -0500 Subject: Add free function for ropes Note: Does free entire tree. --- structures/rope/rope.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/structures/rope/rope.c b/structures/rope/rope.c index 6e79b24..4719b18 100644 --- a/structures/rope/rope.c +++ b/structures/rope/rope.c @@ -28,6 +28,21 @@ rope* rope_new() return tmp; } +void rope_free(root) +rope *root; +{ + if (root->str) + free(root->str); + if (root->left) + free(root->left); + if (root->right) + free(root->right); + + free(root); + + return; +} + void rope_debug_print_aux(root, s) rope *root; int s; -- cgit v1.1