I seem to have a problem with reallocating memory of arrays inside a function. Whenever the code gets to realloc, it is shut down due to Segmentation fault.
I call malloc in main:
char* coded_message = (char*) malloc(BASE_LENGTH * sizeof(char));
read_input(&coded_message, &original_message, &char_counter);
Than pass it to a function, which is reading input an if needed be reallocates the memory. So I the function goes like this:
int read_input(char** coded_message){
...
*coded_message = (char*) realloc(*coded_message, (counter + REALLOC_LENGTH) * sizeof(char));
...
}