I have:
char *data = malloc(file_size+1);
I also have strings such as char *string = "string1"
.
I want to be able to realloc memory to data whenever I'm about to add another string to data. What would be the best way to do this in C, I've seen other ways such as using file_size * 2, however, this would be a waste of memory, what is the best way to do this when adding the length of a string to the memory. This is for a simple desktop application.