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