have since found this:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void foo(char **string, char size)
{
*string = realloc(*string, size * sizeof **string);
if (*string == NULL) {
fprintf(stderr, "Memory exhausted\n");
exit(EXIT_FAILURE);
}
}
int main(void)
{
char size = 6;
char *string1;
string1 = malloc(size);
sprintf(string1, "Hello");
size *=2;
foo(&string1, size);
strcat(string1, " World");
printf("%s", string1);
}