[tracker/wal: 17/18] libtracker-data: Don't leak in_use_filename in db-manager



commit 2644b553687050ac6ea3fb85dad75c8947e8025d
Author: Martyn Russell <martyn lanedo com>
Date:   Thu Jul 22 17:27:56 2010 +0100

    libtracker-data: Don't leak in_use_filename in db-manager

 src/libtracker-data/tracker-db-manager.c |   31 +++++++++--------------------
 1 files changed, 10 insertions(+), 21 deletions(-)
---
diff --git a/src/libtracker-data/tracker-db-manager.c b/src/libtracker-data/tracker-db-manager.c
index 0d98132..9bbaf26 100644
--- a/src/libtracker-data/tracker-db-manager.c
+++ b/src/libtracker-data/tracker-db-manager.c
@@ -145,6 +145,7 @@ static gchar                *sql_dir;
 static gchar                *data_dir = NULL;
 static gchar                *user_data_dir = NULL;
 static gchar                *sys_tmp_dir = NULL;
+static gchar                *in_use_filename = NULL;
 static gpointer              db_type_enum_class_pointer;
 static TrackerDBManagerFlags old_flags = 0;
 
@@ -590,7 +591,6 @@ tracker_db_manager_init (TrackerDBManagerFlags  flags,
 	const gchar        *env_path;
 	gboolean            need_reindex;
 	guint               i;
-	gchar              *in_use_filename;
 	int                 in_use_file;
 	gboolean            loaded = FALSE;
 	TrackerDBInterface *resources_iface;
@@ -654,6 +654,12 @@ tracker_db_manager_init (TrackerDBManagerFlags  flags,
 	                             "tracker",
 	                             NULL);
 
+	in_use_filename = g_build_filename (g_get_user_data_dir (),
+	                                    "tracker",
+	                                    "data",
+	                                    IN_USE_FILENAME,
+	                                    NULL);
+
 	/* Make sure the directories exist */
 	g_message ("Checking database directories exist");
 
@@ -720,12 +726,6 @@ tracker_db_manager_init (TrackerDBManagerFlags  flags,
 		tracker_db_interface_sqlite_enable_shared_cache ();
 	}
 
-	in_use_filename = g_build_filename (g_get_user_data_dir (),
-	                                    "tracker",
-	                                    "data",
-	                                    IN_USE_FILENAME,
-	                                    NULL);
-
 	/* Should we reindex? If so, just remove all databases files,
 	 * NOT the paths, note, that these paths are also used for
 	 * other things like the nfs lock file.
@@ -850,7 +850,6 @@ tracker_db_manager_init (TrackerDBManagerFlags  flags,
 
 	if ((flags & TRACKER_DB_MANAGER_READONLY) == 0) {
 		/* do not create in-use file for read-only mode (direct access) */
-
 		in_use_file = g_open (in_use_filename,
 			              O_WRONLY | O_APPEND | O_CREAT | O_SYNC,
 			              S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
@@ -861,8 +860,6 @@ tracker_db_manager_init (TrackerDBManagerFlags  flags,
 		}
 	}
 
-	g_free (in_use_filename);
-
 	initialized = TRUE;
 
 	thread_ifaces = g_hash_table_new (NULL, NULL);
@@ -946,19 +943,11 @@ tracker_db_manager_shutdown (void)
 
 	if ((tracker_db_manager_get_flags () & TRACKER_DB_MANAGER_READONLY) == 0) {
 		/* do not delete in-use file for read-only mode (direct access) */
-
-		gchar *in_use_filename;
-
-		in_use_filename = g_build_filename (g_get_user_data_dir (),
-			                            "tracker",
-			                            "data",
-			                            IN_USE_FILENAME,
-			                            NULL);
-
 		g_unlink (in_use_filename);
-
-		g_free (in_use_filename);
 	}
+
+	g_free (in_use_filename);
+        in_use_filename = NULL;
 }
 
 void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]