char* read_config_file(const char* filename)
{
- char* config_stream = NULL;
-
FILE* config_file = fopen(filename, "r");
int char_count = 0;
while(fread(buf, sizeof(char), 1, config_file)) {
char_count++;
}
+ free(buf);
+ buf = NULL;
fseek(config_file, 0L, SEEK_SET);
- config_stream = malloc(sizeof(char) * char_count);
+ char* config_stream = malloc(sizeof(char) * char_count);
fread(config_stream, char_count, 1, config_file);
+ config_stream[char_count - 1 ] = '\0';
fclose(config_file);
config_file = NULL;