Skip to content

Commit

Permalink
Some memory leak fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Clasen committed Dec 4, 2016
1 parent 1ee9c54 commit 98bc87e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/gr-recipe-exporter.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Copyright (C) 2016 Matthias Clasen <[email protected]>
*
* Licensed under the GNU General Public License Version 3
<file preprocess="xml-stripblanks">gr-big-cuisine-tile.ui</file>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -253,7 +254,6 @@ prepare_export (GrRecipeExporter *exporter,
j++;
}


g_key_file_set_string (keyfile, key, "Name", name ? name : "");
g_key_file_set_string (keyfile, key, "Author", author ? author : "");
g_key_file_set_string (keyfile, key, "Description", description ? description : "");
Expand Down Expand Up @@ -295,9 +295,12 @@ prepare_export (GrRecipeExporter *exporter,
return FALSE;
}

g_free (path);
path = g_build_filename (exporter->dir, "chefs.db", NULL);
g_clear_pointer (&path, g_free);
g_clear_pointer (&name, g_free);
g_clear_pointer (&description, g_free);
g_clear_pointer (&keyfile, g_key_file_unref);

path = g_build_filename (exporter->dir, "chefs.db", NULL);
keyfile = g_key_file_new ();

key = name = gr_chef_get_name (chef);
Expand Down
4 changes: 2 additions & 2 deletions src/gr-recipe-store.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,11 @@ load_recipes (GrRecipeStore *self,
}
if (tmp) {
ctime = date_time_from_string (tmp);
g_free (tmp);
if (!ctime) {
g_warning ("Failed to load recipe %s: Couldn't parse Created key", groups[i]);
continue;
}
g_free (tmp);
}
else {
ctime = g_date_time_new_now_utc ();
Expand All @@ -378,11 +378,11 @@ load_recipes (GrRecipeStore *self,
}
if (tmp) {
mtime = date_time_from_string (tmp);
g_free (tmp);
if (!mtime) {
g_warning ("Failed to load recipe %s: Couldn't parse Modified key", groups[i]);
continue;
}
g_free (tmp);
}
else {
mtime = g_date_time_new_now_utc ();
Expand Down
4 changes: 4 additions & 0 deletions src/gr-recipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ gr_recipe_finalize (GObject *object)
g_free (priv->cf_name);
g_free (priv->cf_description);
g_free (priv->cf_ingredients);
g_date_time_unref (priv->mtime);
g_date_time_unref (priv->ctime);

G_OBJECT_CLASS (gr_recipe_parent_class)->finalize (object);
}
Expand Down Expand Up @@ -226,13 +228,15 @@ gr_recipe_set_property (GObject *object,

case PROP_NAME:
g_free (priv->name);
g_free (priv->cf_name);
priv->name = g_value_dup_string (value);
priv->cf_name = g_utf8_casefold (priv->name, -1);
update_mtime (self);
break;

case PROP_DESCRIPTION:
g_free (priv->description);
g_free (priv->cf_description);
priv->description = g_value_dup_string (value);
priv->cf_description = g_utf8_casefold (priv->description, -1);
update_mtime (self);
Expand Down

0 comments on commit 98bc87e

Please sign in to comment.