Maybe use asprintf for this?