[Suspend2][ 3/9] [Suspend2] Free a whole extent chain.

Nigel Cunningham
2006-06-26T16:56:05Z

Add a routine to free an entire extent chain at once.

Signed-off-by: Nigel Cunningham <nigel@suspend2.net>

kernel/power/extent.c | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/kernel/power/extent.c b/kernel/power/extent.c
index 2fb6a23..ab19509 100644
--- a/kernel/power/extent.c
+++ b/kernel/power/extent.c
@@ -47,3 +47,26 @@ void suspend_put_extent(struct extent *e
suspend_extents_allocated--;
}

+/* suspend_put_extent_chain.
+ *
+ * Frees a whole chain of extents.
+ */
+void suspend_put_extent_chain(struct extent_chain *chain)
+{
+ struct extent *this;
+
+ this = chain->first;
+
+ while(this) {
+ struct extent *next = this->next;
+ kfree(this);
+ chain->frees++;
+ suspend_extents_allocated --;
+ this = next;
+ }
+
+ BUG_ON(chain->frees != chain->allocs);
+ chain->first = chain->last = chain->last_touched = NULL;
+ chain->size = chain->allocs = chain->frees = 0;
+}
+

--
Nigel Cunningham nigel at suspend2 dot net