From: Bastian Dehn Date: Fri, 14 Feb 2025 16:53:29 +0000 (+0100) Subject: change read config file seek size X-Git-Tag: v1.0.36^2~10 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=3f21e7afbc283f4c7f1365dda3bce99c67c38932;p=sane-kds-s2000w-net.git change read config file seek size --- diff --git a/src/kds_s2000w_config.c b/src/kds_s2000w_config.c index a16e311..5d24782 100644 --- a/src/kds_s2000w_config.c +++ b/src/kds_s2000w_config.c @@ -18,13 +18,9 @@ void _kds_s2000w_config_copy_string_to_config_value(cfg_t* cfg, const char* key, 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);