You should use `asprintf` instead of doing this with calloc + strcat.