char* kds_s2000w_config_read(const char* filename)
{
FILE* config_file = fopen(filename, "r");
- size_t config_size = 0;
-
- char buf = 0;
- while (fread(&buf, sizeof(char), 1, config_file) > 0) {
- config_size++;
- }
- fseek(config_file, 0, SEEK_SET);
+ fseek(config_file, 0, SEEK_END);
+ size_t config_size = ftell(config_file);
+ rewind(config_file);
char* config_string = malloc(sizeof(char) * config_size + 1);
fread(config_string, config_size, 1, config_file);