Wrote mem_init function.