fix: memory leaks regarded to glib

This commit is contained in:
Sven Vogel 2024-10-10 20:44:29 +02:00
parent 8d748038c0
commit 27a4d6e465
2 changed files with 11 additions and 5 deletions

View File

@ -285,13 +285,18 @@ static int compile_module_with_dependencies(ModuleFileStack* unit,
GPathBuf* dep_bin = g_path_buf_new();
g_path_buf_push(dep_bin, dependency->mode.project.path);
g_path_buf_push(dep_bin, dep_conf->archive_directory);
g_path_buf_push(dep_bin, g_strjoin(".", dep_conf->name, "o", NULL));
char* dep_bin_path = g_path_buf_to_path(dep_bin);
char* dep_obj_file = g_strjoin(".", dep_conf->name, "o", NULL);
g_path_buf_push(dep_bin, dep_obj_file);
char* dep_bin_path = g_path_buf_free_to_path(dep_bin);
g_free(dep_obj_file);
char* cached_dep_bin_path = mem_strdup(MemoryNamespaceLld, dep_bin_path);
g_free(dep_bin_path);
g_array_append_val(dependency->libraries, dep_bin_path);
g_array_append_val(dependency->libraries, cached_dep_bin_path);
const char* path =
get_absolute_import_path(target, rel_path);
g_free(rel_path);
if (g_hash_table_contains(imports, path)) {
continue;
@ -311,13 +316,14 @@ static int compile_module_with_dependencies(ModuleFileStack* unit,
g_hash_table_insert(imports, (gpointer) path, NULL);
g_path_buf_pop(buf);
gchar* directory = g_path_buf_to_path(buf);
gchar* directory = g_path_buf_free_to_path(buf);
gchar* cached_directory =
mem_strdup(MemoryNamespaceLld, directory);
g_free(directory);
g_array_append_val(target->import_paths, cached_directory);
chdir(cwd);
g_free(cwd);
GHashTableIter iter;

View File

@ -2094,7 +2094,7 @@ char* module_ref_to_string(AST_NODE_PTR node) {
char* composed = g_strjoin("::", curmodule, submodule, NULL);
char* cached_composed = mem_strdup(MemoryNamespaceSet, composed);
mem_free(composed);
g_free(composed);
mem_free(curmodule);
mem_free(submodule);