void getData(char** dst) {
*dst = malloc(sizeof(char) * 50);
if (*dst == NULL) {
fprintf(stderr, "Memory allocation failed\n");
return;
}
sprintf(*dst, "This is a test.\r\n");
}
Directly allocates memory to *dst and check you can allocate memory.