/* Determine the largest available block size. 
Calculates the largest block which can be allocated by the Membag allocator if requested. Allocations larger than this amount are guaranteed to fail. */
size_t membag_get_largest_free_block_size(void)
/* Determine the largest available block size. 
Calculates the largest block which can be allocated by the Membag allocator if requested. Allocations larger than this amount are guaranteed to fail. */
size_t membag_get_largest_free_block_size(void)
{
	uint8_t i;
	struct membag *largest_bag = NULL;
	for (i = 0; i < ARRAY_LEN(membag_list); i++) {
		if (membag_list[i].blocks_free == 0) {
			continue;
		}
		if (!largest_bag ||
				(largest_bag->block_size < membag_list[i].block_size)) {
			largest_bag = &membag_list[i];
		}
	}
	if (largest_bag) {
		return largest_bag->block_size;
	}
	return 0;
}