Refactor: various: improve string allocation
Where appropriate, replace calls to malloc(), calloc(), and asprintf() with
calls to strdup(), strndup(), crm_itoa(), or crm_strdup_printf().
This improves readability, reduces the chance for programmer mistakes, and in
the case of crm_itoa() and crm_strdup_printf(), adds an assertion in case the
allocation fails.