diff options
Diffstat (limited to 'mboxd_windows.c')
-rw-r--r-- | mboxd_windows.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/mboxd_windows.c b/mboxd_windows.c index c64d19b..f02b0d7 100644 --- a/mboxd_windows.c +++ b/mboxd_windows.c @@ -479,6 +479,30 @@ struct window_context *find_oldest_window(struct mbox_context *context) } /* + * find_largest_window() - Find the largest window in the window cache + * @context: The mbox context pointer + * + * Return: The largest window + */ +struct window_context *find_largest_window(struct mbox_context *context) +{ + struct window_context *largest = NULL, *cur; + uint32_t max_size = 0; + int i; + + for (i = 0; i < context->windows.num; i++) { + cur = &context->windows.window[i]; + + if (cur->size > max_size) { + max_size = cur->size; + largest = cur; + } + } + + return largest; +} + +/* * search_windows() - Search the window cache for a window containing offset * @context: The mbox context pointer * @offset: Absolute flash offset to search for (bytes) |