Open FabianHahn opened 4 years ago
g_hash_table_add currently just wraps g_hash_table_replace in a macro. However, this is problematic when calling it with things like string keys that are managed by the hash table:
g_hash_table_add
g_hash_table_replace
void addItemToSet(GHashTable *table, const char *key) { g_hash_table_add(table, strdup(key)); }
Because of the macro, this will end up calling strdup twice and leaking the memory for the second copy.
strdup
g_hash_table_add
currently just wrapsg_hash_table_replace
in a macro. However, this is problematic when calling it with things like string keys that are managed by the hash table:Because of the macro, this will end up calling
strdup
twice and leaking the memory for the second copy.