Implement `xstrdup` and `xstrndup`

Utility functions for copying strings to newly-allocated chunks. They either
succeed or exit the program.
Replace `strdup` calls by `xstrdup`