[tracker/tracker-0.6] Fixed utils/qdbm/ print-words and search-word based on coverity
- From: Martyn James Russell <mr src gnome org>
- To: svn-commits-list gnome org
- Subject: [tracker/tracker-0.6] Fixed utils/qdbm/ print-words and search-word based on coverity
- Date: Wed, 13 May 2009 10:59:57 -0400 (EDT)
commit 613018247d78aca34b3b70b36695d6a18df6e5e5
Author: Martyn Russell <martyn imendio com>
Date: Wed May 13 15:00:58 2009 +0100
Fixed utils/qdbm/ print-words and search-word based on coverity
---
utils/qdbm/print-words.c | 13 ++++++++-----
utils/qdbm/search-word.c | 8 ++++++--
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/utils/qdbm/print-words.c b/utils/qdbm/print-words.c
index 44c7c7d..0a51222 100644
--- a/utils/qdbm/print-words.c
+++ b/utils/qdbm/print-words.c
@@ -81,7 +81,7 @@ load_terms_from_index (gchar *filename)
depot = dpopen (filename, DP_OREADER | DP_ONOLCK, -1);
- if (depot == NULL) {
+ if (!depot) {
g_print ("Unable to open file: %s "
"(Could be a lock problem: is tracker running?)\n",
filename);
@@ -92,27 +92,30 @@ load_terms_from_index (gchar *filename)
dpiterinit (depot);
- key = dpiternext (depot, NULL);
-
- while (key != NULL) {
+ for (key = dpiternext (depot, NULL);
+ key != NULL;
+ key = dpiternext (depot, NULL)) {
g_print (" - %s ", key);
if (print_services) {
results = get_word_hits (depot, key, &hits);
+
for (i = 0; i < hits; i++) {
g_print (" (id:%d t:%d s:%d) ",
tracker_db_index_item_get_id (&results[i]),
tracker_db_index_item_get_service_type (&results[i]),
tracker_db_index_item_get_score (&results[i]));
}
+
+ g_free (results);
}
g_print ("\n");
g_free (key);
- key = dpiternext (depot, NULL);
}
g_print ("Total: %d terms.\n", dprnum (depot));
+
dpclose (depot);
}
diff --git a/utils/qdbm/search-word.c b/utils/qdbm/search-word.c
index 45e9dc6..342c57b 100644
--- a/utils/qdbm/search-word.c
+++ b/utils/qdbm/search-word.c
@@ -81,7 +81,7 @@ show_term_in_index (const gchar *filename,
depot = dpopen (filename, DP_OREADER, -1);
- if (depot == NULL) {
+ if (!depot) {
g_print ("Unable to open file: %s "
"(Could be a lock problem: is tracker running?)\n",
filename);
@@ -92,8 +92,10 @@ show_term_in_index (const gchar *filename,
items = get_word_hits (depot, word, &hits);
- if (hits < 1 ) {
+ if (hits < 1) {
g_print ("No results for %s\n", word);
+ g_free (items);
+ dpclose (depot);
return;
}
@@ -108,6 +110,8 @@ show_term_in_index (const gchar *filename,
g_print ("\n");
g_print ("Total: %d terms.\n", dprnum (depot));
+
+ g_free (items);
dpclose (depot);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]