malloc in Example4 moved otuside the loop