Skip to content

Commit

Permalink
Fix de memoria al hacer el config_set_value
Browse files Browse the repository at this point in the history
No era necesario duplicar la key en el config_set_value porque esto ya lo hace el dictionary_put
  • Loading branch information
gastonprieto committed Jun 19, 2017
1 parent 50239d5 commit 1dd52d0
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/commons/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,13 @@ void config_destroy(t_config *config) {

void config_set_value(t_config *self, char *key, char *value) {
t_dictionary* dictionary = self->properties;
char* duplicate_key;
char* duplicate_value;

duplicate_key=string_duplicate(key);
duplicate_value=string_duplicate(value);
char* duplicate_value = string_duplicate(value);

if(dictionary_has_key(dictionary, key)) {
dictionary_remove_and_destroy(dictionary, key, free);
}
dictionary_put(self->properties,duplicate_key,(void*)duplicate_value);

dictionary_put(self->properties, key, (void*)duplicate_value);
}

int config_save(t_config *self) {
Expand Down

0 comments on commit 1dd52d0

Please sign in to comment.