/* Initialize the membag system. 
This function sets up the membags, allocates memory from the memory pool, and initializes them. Any existing allocations are destroyed and all memory pools reset to their initial states.  */
void membag_init(void)
/* Initialize the membag system. 
This function sets up the membags, allocates memory from the memory pool, and initializes them. Any existing allocations are destroyed and all memory pools reset to their initial states.  */
void membag_init(void)
{
	uint8_t i;
	uintptr_t poolptr;
	poolptr = (uintptr_t)membag_pool;
	for (i = 0; i < ARRAY_LEN(membag_list); i++) {
		Assert(membag_list[i].block_size > 0);
		Assert(membag_list[i].num_blocks > 0);
		Assert(membag_list[i].num_blocks <= 32);
		membag_list[i].start = poolptr;
		poolptr += (membag_list[i].block_size *
				membag_list[i].num_blocks);
		membag_list[i].end = poolptr;
		membag_list[i].blocks_free = membag_list[i].num_blocks;
		membag_list[i].allocated = 0;
	}
}