add end and free malloc