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

Should these be `*bufelem`?