refactor(optimize): use fixed size strings everywhere except for files

This commit is contained in:
2025-11-02 17:35:37 +01:00
parent b8bc021e69
commit 54ce876f6a
11 changed files with 52 additions and 49 deletions
+5 -4
View File
@@ -3,6 +3,7 @@
#include <stdlib.h>
#include <string.h>
#include "config.h"
#include "config_file.h"
#include "file.h"
#include "string.h"
@@ -61,7 +62,7 @@ static void parse_config_file_line(ConfigFile config, char *line) {
hashmap_set(config.map, &item);
}
ConfigFile config_file_read(char *path, bool free_path) {
ConfigFile config_file_read(char *path) {
File file;
ConfigFile config;
char *line;
@@ -82,7 +83,7 @@ ConfigFile config_file_read(char *path, bool free_path) {
line = strtok(NULL, "\n");
}
file_free(&file, free_path);
file_free(&file);
return config;
}
@@ -91,7 +92,7 @@ char *config_file_get_str(ConfigFile config, char *key, char *default_value) {
ConfigFileItem c_key;
ConfigFileItem *item;
strcpy(c_key.key, key);
strncpy(c_key.key, key, STR_LEN);
item = (ConfigFileItem *)hashmap_get(config.map, &c_key);
@@ -107,7 +108,7 @@ unsigned int config_file_get_int(ConfigFile config, char *key,
ConfigFileItem c_key;
ConfigFileItem *item;
strcpy(c_key.key, key);
strncpy(c_key.key, key, STR_LEN);
item = (ConfigFileItem *)hashmap_get(config.map, &c_key);