libstd: refine dynamic memory allocations in os::getcwd() and os::change_dir()

`bufv.extend(&mut u16iter)`