[tracker/binary-log-2: 7/42] Move local functions above public functions



commit ad394126a8beccdcff0b58a13196ac7f312ca23b
Author: Martyn Russell <martyn lanedo com>
Date:   Mon Jan 4 14:37:01 2010 +0000

    Move local functions above public functions

 src/libtracker-db/tracker-db-journal.c |  121 ++++++++++++++++----------------
 1 files changed, 61 insertions(+), 60 deletions(-)
---
diff --git a/src/libtracker-db/tracker-db-journal.c b/src/libtracker-db/tracker-db-journal.c
index ccc6bc0..1e4cd57 100644
--- a/src/libtracker-db/tracker-db-journal.c
+++ b/src/libtracker-db/tracker-db-journal.c
@@ -63,28 +63,39 @@ static struct {
 	guint cur_pos;
 } writer;
 
-gsize
-tracker_db_journal_get_size (void)
+static guint32
+read_uint32 (const gchar *data)
 {
-	return current_size;
+	return data[0] << 24 |
+	       data[1] << 16 |
+	       data[2] << 8 |
+	       data[3];
 }
 
-const gchar *
-tracker_db_journal_filename (void)
+static gint
+nearest_pow (gint num)
 {
-	if (!writer.filename) {
-		writer.filename = g_build_filename (g_get_user_data_dir (),
-		                                    "tracker",
-		                                    "data",
-		                                    JOURNAL_LOG_FILENAME,
-		                                    NULL);
-	}
+	gint n = 1;
+	while (n < num)
+		n <<= 1;
+	return n;
+}
 
-	return filename;
+static void
+cur_block_maybe_expand (guint len)
+{
+	guint want_alloc = writer.cur_block_len + len;
+
+	if (want_alloc > writer.cur_block_alloc) {
+		want_alloc = nearest_pow (want_alloc);
+		want_alloc = MAX (want_alloc, MIN_BLOCK_SIZE);
+		writer.cur_block = g_realloc (writer.cur_block, want_alloc);
+		writer.cur_block_alloc = want_alloc;
+	}
 }
 
 static void
-kill_cur_block (void)
+cur_block_kill (void)
 {
 	writer.cur_block_len = 0;
 	writer.cur_pos = 0;
@@ -94,26 +105,46 @@ kill_cur_block (void)
 	writer.cur_block = NULL;
 }
 
-static gint
-nearest_pow (gint num)
+static void
+cur_setnum (gchar   *dest,
+            guint   *pos,
+            guint32  val)
 {
-	gint n = 1;
-	while (n < num)
-		n <<= 1;
-	return n;
+	memset (dest + (*pos)++, val >> 24 & 0xff, 1);
+	memset (dest + (*pos)++, val >> 16 & 0xff, 1);
+	memset (dest + (*pos)++, val >>  8 & 0xff, 1);
+	memset (dest + (*pos)++, val >>  0 & 0xff, 1);
 }
 
 static void
-cur_block_maybe_expand (guint len)
+cur_setstr (gchar       *dest,
+            guint       *pos,
+            const gchar *str,
+            gsize        len)
 {
-	guint want_alloc = writer.cur_block_len + len;
+	memcpy (dest + *pos, str, len);
+	(*pos) += len;
+	memset (dest + (*pos)++, 0 & 0xff, 1);
+}
 
-	if (want_alloc > writer.cur_block_alloc) {
-		want_alloc = nearest_pow (want_alloc);
-		want_alloc = MAX (want_alloc, MIN_BLOCK_SIZE);
-		writer.cur_block = g_realloc (writer.cur_block, want_alloc);
-		writer.cur_block_alloc = want_alloc;
+gsize
+tracker_db_journal_get_size (void)
+{
+	return current_size;
+}
+
+const gchar *
+tracker_db_journal_filename (void)
+{
+	if (!writer.filename) {
+		writer.filename = g_build_filename (g_get_user_data_dir (),
+		                                    "tracker",
+		                                    "data",
+		                                    JOURNAL_LOG_FILENAME,
+		                                    NULL);
 	}
+
+	return filename;
 }
 
 void
@@ -160,7 +191,7 @@ tracker_db_journal_open (const gchar *filen)
 
 		writer.current_size += 8;
 
-		kill_cur_block ();
+		cur_block_kill ();
 	}
 }
 
@@ -181,28 +212,6 @@ tracker_db_journal_start_transaction (void)
 	writer.cur_entry_amount = 0;
 }
 
-static void
-cur_setnum (gchar   *dest,
-            guint   *pos,
-            guint32  val)
-{
-	memset (dest + (*pos)++, val >> 24 & 0xff, 1);
-	memset (dest + (*pos)++, val >> 16 & 0xff, 1);
-	memset (dest + (*pos)++, val >>  8 & 0xff, 1);
-	memset (dest + (*pos)++, val >>  0 & 0xff, 1);
-}
-
-static void
-cur_setstr (gchar       *dest,
-            guint       *pos,
-            const gchar *str,
-            gsize        len)
-{
-	memcpy (dest + *pos, str, len);
-	(*pos) += len;
-	memset (dest + (*pos)++, 0 & 0xff, 1);
-}
-
 void
 tracker_db_journal_append_delete_statement (guint32      s_id,
                                             guint32      p_id,
@@ -303,7 +312,7 @@ tracker_db_journal_append_resource (guint32      s_id,
 void
 tracker_db_journal_rollback_transaction (void)
 {
-	kill_cur_block ();
+	cur_block_kill ();
 }
 
 void
@@ -334,7 +343,7 @@ tracker_db_journal_commit_transaction (void)
 
 	writer.current_size += writer.cur_block_len;
 
-	kill_cur_block ();
+	cur_block_kill ();
 }
 
 void 
@@ -377,14 +386,6 @@ tracker_db_journal_reader_init (const gchar *filen)
 	journal_reader.current += 8;
 }
 
-static guint32 read_uint32 (const gchar *data)
-{
-	return data[0] << 24 |
-	       data[1] << 16 |
-	       data[2] << 8 |
-	       data[3];
-}
-
 gboolean
 tracker_db_journal_next (void)
 {



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