[tracker/return-types: 27/28] Fixed coding style issues



commit 5ae660d8ce8baef6e9e6b798d1523e940d94927f
Author: Martyn Russell <martyn lanedo com>
Date:   Wed Sep 15 15:01:46 2010 +0100

    Fixed coding style issues

 src/libtracker-bus/tracker-bus-fd-cursor.c        |   22 ++++---
 src/libtracker-client/tracker.c                   |    6 +-
 src/libtracker-common/tracker-dbus.c              |   81 +++++++++------------
 src/libtracker-data/tracker-db-interface-sqlite.c |   75 +++++++++++---------
 4 files changed, 92 insertions(+), 92 deletions(-)
---
diff --git a/src/libtracker-bus/tracker-bus-fd-cursor.c b/src/libtracker-bus/tracker-bus-fd-cursor.c
index 760f5ee..f7e9cb5 100644
--- a/src/libtracker-bus/tracker-bus-fd-cursor.c
+++ b/src/libtracker-bus/tracker-bus-fd-cursor.c
@@ -105,10 +105,10 @@ tracker_bus_fd_cursor_iter_next (TrackerBusFDCursor  *cursor,
 
 	/* Storage of ints that will be casted to TrackerSparqlValueType enums,
 	 * also see tracker_bus_fd_cursor_get_value_type */
-	cursor->types = (int *)(cursor->buffer + cursor->buffer_index);
+	cursor->types = (int*) cursor->buffer + cursor->buffer_index;
 	cursor->buffer_index += sizeof (int) * (cursor->n_columns);
 
-	cursor->offsets = (int *)(cursor->buffer + cursor->buffer_index);
+	cursor->offsets = (int*) cursor->buffer + cursor->buffer_index;
 	cursor->buffer_index += sizeof (int) * (cursor->n_columns - 1);
 	last_offset = buffer_read_int (cursor);
 
@@ -169,7 +169,8 @@ tracker_bus_fd_cursor_get_n_columns (TrackerBusFDCursor *cursor)
 }
 
 static TrackerSparqlValueType
-tracker_bus_fd_cursor_get_value_type (TrackerBusFDCursor *cursor,  guint column)
+tracker_bus_fd_cursor_get_value_type (TrackerBusFDCursor *cursor,
+                                      guint               column)
 {
 	g_return_val_if_fail (cursor->types != NULL, TRACKER_SPARQL_VALUE_TYPE_UNBOUND);
 
@@ -177,8 +178,9 @@ tracker_bus_fd_cursor_get_value_type (TrackerBusFDCursor *cursor,  guint column)
 	return (TrackerSparqlValueType) cursor->types[column];
 }
 
-static const gchar*
-tracker_bus_fd_cursor_get_variable_name (TrackerBusFDCursor *cursor,  guint column)
+static const gchar *
+tracker_bus_fd_cursor_get_variable_name (TrackerBusFDCursor *cursor,
+                                         guint               column)
 {
 	g_return_val_if_fail (cursor->variable_names != NULL, NULL);
 
@@ -242,8 +244,10 @@ tracker_bus_fd_cursor_finalize (GObject *object)
 
 	cursor = TRACKER_BUS_FD_CURSOR (object);
 
-	if (cursor->variable_names)
+	if (cursor->variable_names) {
 		g_strfreev (cursor->variable_names);
+	}
+
 	g_free (cursor->buffer);
 
 	G_OBJECT_CLASS (tracker_bus_fd_cursor_parent_class)->finalize (object);
@@ -288,14 +292,14 @@ tracker_bus_fd_query (DBusGConnection  *gconnection,
 	cursor = g_object_new (TRACKER_TYPE_BUS_FD_CURSOR, NULL);
 
 	/* Cast from long* to gssize*, no idea why the API isn't matching. Silencing
-	 * compiler-warning. In tracker.c it's gssize* all the way */
-
+	 * compiler-warning. In tracker.c it's gssize* all the way
+	 */
 	tracker_dbus_send_and_splice (connection,
 	                              message,
 	                              pipefd[0],
 	                              cancellable,
 	                              (void **) &cursor->buffer,
-	                              (gssize *) &cursor->buffer_size,
+	                              &cursor->buffer_size,
 	                              &cursor->variable_names,
 	                              &inner_error);
 
diff --git a/src/libtracker-client/tracker.c b/src/libtracker-client/tracker.c
index 08641a0..7109b84 100644
--- a/src/libtracker-client/tracker.c
+++ b/src/libtracker-client/tracker.c
@@ -1823,15 +1823,15 @@ tracker_result_iterator_next (TrackerResultIterator *iterator)
 	/* So, the make up on each iterator segment is:
 	 *
 	 * iteration = [4 bytes for number of columns,
-	 *              columns x 4 bytes for types 
+	 *              columns x 4 bytes for types
 	 *              columns x 4 bytes for offsets]
 	 */
 	iterator->n_columns = iterator_buffer_read_int (iterator);
 
-	iterator->types = (int *)(iterator->buffer + iterator->buffer_index);
+	iterator->types = (int*) iterator->buffer + iterator->buffer_index;
 	iterator->buffer_index += sizeof (int) * (iterator->n_columns);
 
-	iterator->offsets = (int *)(iterator->buffer + iterator->buffer_index);
+	iterator->offsets = (int*) iterator->buffer + iterator->buffer_index;
 	iterator->buffer_index += sizeof (int) * (iterator->n_columns - 1);
 
 	last_offset = iterator_buffer_read_int (iterator);
diff --git a/src/libtracker-common/tracker-dbus.c b/src/libtracker-common/tracker-dbus.c
index faa38b3..fb129fe 100644
--- a/src/libtracker-common/tracker-dbus.c
+++ b/src/libtracker-common/tracker-dbus.c
@@ -706,6 +706,39 @@ tracker_dbus_enable_client_lookup (gboolean enabled)
 	client_lookup_enabled = enabled;
 }
 
+static GStrv
+dbus_send_and_splice_get_variable_names (DBusMessage *message,
+                                         gboolean     copy_strings)
+{
+	GStrv v_names;
+	GPtrArray *found;
+	DBusMessageIter iter, arr;
+	guint i;
+
+	dbus_message_iter_init (message, &iter);
+	dbus_message_iter_recurse (&iter, &arr);
+
+	found = g_ptr_array_new ();
+
+	while (dbus_message_iter_get_arg_type (&arr) != DBUS_TYPE_INVALID) {
+		gchar *str;
+
+		/* Make a copy here, we wont own when returning */
+		dbus_message_iter_get_basic (&arr, &str);
+		g_ptr_array_add (found, copy_strings ? g_strdup (str) : str);
+		dbus_message_iter_next (&arr);
+	}
+
+	v_names = g_new0 (gchar *, found->len + 1);
+	for (i = 0; i < found->len; i++) {
+		v_names[i] = g_ptr_array_index (found, i);
+	}
+
+	g_ptr_array_free (found, TRUE);
+
+	return v_names;
+}
+
 /*
  * /!\ BIG FAT WARNING /!\
  * The message must be destroyed for this function to succeed, so pass a
@@ -787,29 +820,7 @@ tracker_dbus_send_and_splice (DBusConnection  *connection,
 			}
 
 			if (variable_names) {
-				GStrv v_names;
-				guint i;
-				GPtrArray *found = g_ptr_array_new ();
-				DBusMessageIter iter, arr;
-
-				dbus_message_iter_init (reply, &iter);
-				dbus_message_iter_recurse (&iter, &arr);
-
-				while (dbus_message_iter_get_arg_type (&arr) != DBUS_TYPE_INVALID) {
-					gchar *str;
-					dbus_message_iter_get_basic (&arr, &str);
-					/* Make a copy here, we wont own when returning */
-					g_ptr_array_add (found, g_strdup (str));
-					dbus_message_iter_next (&arr);
-				}
-
-				v_names = g_new0 (gchar *, found->len + 1);
-				for (i = 0; i < found->len; i++) {
-					v_names[i] = g_ptr_array_index (found, i);
-				}
-
-				*variable_names = v_names;
-				g_ptr_array_free (found, TRUE);
+				*variable_names = dbus_send_and_splice_get_variable_names (reply, TRUE);
 			}
 
 			ret_value = TRUE;
@@ -910,29 +921,7 @@ send_and_splice_async_callback (GObject      *source,
 			GStrv v_names = NULL;
 
 			if (data->expect_variable_names) {
-				guint i;
-				GPtrArray *found = g_ptr_array_new ();
-				DBusMessageIter iter, arr;
-
-				dbus_message_iter_init (reply, &iter);
-				dbus_message_iter_recurse (&iter, &arr);
-
-				while (dbus_message_iter_get_arg_type (&arr) != DBUS_TYPE_INVALID) {
-					gchar *str;
-
-					/* No need for a copy here, we own it. But then don't use
-					 * g_strfreev lower */
-					dbus_message_iter_get_basic (&arr, &str);
-					g_ptr_array_add (found, str);
-					dbus_message_iter_next (&arr);
-				}
-
-				v_names = g_new0 (gchar *, found->len + 1);
-				for (i = 0; i < found->len; i++) {
-					v_names[i] = g_ptr_array_index (found, i);
-				}
-
-				g_ptr_array_free (found, TRUE);
+				v_names = dbus_send_and_splice_get_variable_names (reply, FALSE);
 			}
 
 			dbus_pending_call_cancel (data->call);
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c b/src/libtracker-data/tracker-db-interface-sqlite.c
index cf0dc24..5e45fa8 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
@@ -1074,8 +1074,8 @@ tracker_db_statement_class_init (TrackerDBStatementClass *class)
 }
 
 static TrackerDBStatement *
-tracker_db_statement_sqlite_new (TrackerDBInterface       *db_interface,
-                                 sqlite3_stmt             *sqlite_stmt)
+tracker_db_statement_sqlite_new (TrackerDBInterface *db_interface,
+                                 sqlite3_stmt       *sqlite_stmt)
 {
 	TrackerDBStatement *stmt;
 
@@ -1195,10 +1195,10 @@ tracker_db_cursor_class_init (TrackerDBCursorClass *class)
 }
 
 static TrackerDBCursor *
-tracker_db_cursor_sqlite_new (sqlite3_stmt              *sqlite_stmt,
-                              TrackerDBStatement        *ref_stmt,
-                              TrackerPropertyType       *types,
-                              gint                       n_types)
+tracker_db_cursor_sqlite_new (sqlite3_stmt        *sqlite_stmt,
+                              TrackerDBStatement  *ref_stmt,
+                              TrackerPropertyType *types,
+                              gint                 n_types)
 {
 	TrackerDBCursor *cursor;
 
@@ -1228,9 +1228,9 @@ tracker_db_cursor_sqlite_new (sqlite3_stmt              *sqlite_stmt,
 }
 
 void
-tracker_db_statement_bind_double (TrackerDBStatement      *stmt,
-                                  int                      index,
-                                  double                   value)
+tracker_db_statement_bind_double (TrackerDBStatement *stmt,
+                                  int                 index,
+                                  double              value)
 {
 	g_return_if_fail (TRACKER_IS_DB_STATEMENT (stmt));
 
@@ -1240,9 +1240,9 @@ tracker_db_statement_bind_double (TrackerDBStatement      *stmt,
 }
 
 void
-tracker_db_statement_bind_int (TrackerDBStatement       *stmt,
-                               int                       index,
-                               gint64                    value)
+tracker_db_statement_bind_int (TrackerDBStatement *stmt,
+                               int                 index,
+                               gint64              value)
 {
 	g_return_if_fail (TRACKER_IS_DB_STATEMENT (stmt));
 
@@ -1252,8 +1252,8 @@ tracker_db_statement_bind_int (TrackerDBStatement       *stmt,
 }
 
 void
-tracker_db_statement_bind_null (TrackerDBStatement        *stmt,
-                                int                        index)
+tracker_db_statement_bind_null (TrackerDBStatement *stmt,
+                                int                 index)
 {
 	g_return_if_fail (TRACKER_IS_DB_STATEMENT (stmt));
 
@@ -1263,9 +1263,9 @@ tracker_db_statement_bind_null (TrackerDBStatement        *stmt,
 }
 
 void
-tracker_db_statement_bind_text (TrackerDBStatement        *stmt,
-                                int                        index,
-                                const gchar               *value)
+tracker_db_statement_bind_text (TrackerDBStatement *stmt,
+                                int                 index,
+                                const gchar        *value)
 {
 	g_return_if_fail (TRACKER_IS_DB_STATEMENT (stmt));
 
@@ -1342,7 +1342,9 @@ tracker_db_cursor_get_n_columns (TrackerDBCursor *cursor)
 }
 
 void
-tracker_db_cursor_get_value (TrackerDBCursor *cursor,  guint column, GValue *value)
+tracker_db_cursor_get_value (TrackerDBCursor *cursor,
+                             guint            column,
+                             GValue          *value)
 {
 	gint col_type;
 
@@ -1371,26 +1373,30 @@ tracker_db_cursor_get_value (TrackerDBCursor *cursor,  guint column, GValue *val
 }
 
 gint64
-tracker_db_cursor_get_int (TrackerDBCursor *cursor,  guint column)
+tracker_db_cursor_get_int (TrackerDBCursor *cursor,
+                           guint            column)
 {
 	return (gint64) sqlite3_column_int64 (cursor->stmt, column);
 }
 
 gdouble
-tracker_db_cursor_get_double (TrackerDBCursor *cursor,  guint column)
+tracker_db_cursor_get_double (TrackerDBCursor *cursor,
+                              guint            column)
 {
 	return (gdouble) sqlite3_column_double (cursor->stmt, column);
 }
 
 static gboolean
-tracker_db_cursor_get_boolean (TrackerSparqlCursor *sparql_cursor,  guint column)
+tracker_db_cursor_get_boolean (TrackerSparqlCursor *sparql_cursor,
+                               guint                column)
 {
 	TrackerDBCursor *cursor = (TrackerDBCursor *) sparql_cursor;
 	return (g_strcmp0 (sqlite3_column_text (cursor->stmt, column), "true") == 0);
 }
 
 TrackerSparqlValueType
-tracker_db_cursor_get_value_type (TrackerDBCursor *cursor,  guint column)
+tracker_db_cursor_get_value_type (TrackerDBCursor *cursor,
+                                  guint            column)
 {
 	gint n_columns = sqlite3_column_count (cursor->stmt);
 
@@ -1419,13 +1425,16 @@ tracker_db_cursor_get_value_type (TrackerDBCursor *cursor,  guint column)
 }
 
 const gchar*
-tracker_db_cursor_get_variable_name (TrackerDBCursor *cursor, guint column)
+tracker_db_cursor_get_variable_name (TrackerDBCursor *cursor,
+                                     guint            column)
 {
 	return sqlite3_column_name (cursor->stmt, column);
 }
 
 const gchar*
-tracker_db_cursor_get_string (TrackerDBCursor *cursor,  guint column, glong *length)
+tracker_db_cursor_get_string (TrackerDBCursor *cursor,
+                              guint            column,
+                              glong           *length)
 {
 	if (length) {
 		sqlite3_value *val = sqlite3_column_value (cursor->stmt, column);
@@ -1437,10 +1446,9 @@ tracker_db_cursor_get_string (TrackerDBCursor *cursor,  guint column, glong *len
 	}
 }
 
-
 TrackerDBResultSet *
-tracker_db_statement_execute (TrackerDBStatement          *stmt,
-                              GError                     **error)
+tracker_db_statement_execute (TrackerDBStatement  *stmt,
+                              GError             **error)
 {
 	g_return_val_if_fail (!stmt->stmt_is_sunk, NULL);
 
@@ -1448,8 +1456,8 @@ tracker_db_statement_execute (TrackerDBStatement          *stmt,
 }
 
 TrackerDBCursor *
-tracker_db_statement_start_cursor (TrackerDBStatement             *stmt,
-                                   GError                        **error)
+tracker_db_statement_start_cursor (TrackerDBStatement  *stmt,
+                                   GError             **error)
 {
 	g_return_val_if_fail (!stmt->stmt_is_sunk, NULL);
 
@@ -1457,17 +1465,16 @@ tracker_db_statement_start_cursor (TrackerDBStatement             *stmt,
 }
 
 TrackerDBCursor *
-tracker_db_statement_start_sparql_cursor (TrackerDBStatement             *stmt,
-                                          TrackerPropertyType            *types,
-                                          gint                            n_types,
-                                          GError                        **error)
+tracker_db_statement_start_sparql_cursor (TrackerDBStatement   *stmt,
+                                          TrackerPropertyType  *types,
+                                          gint                  n_types,
+                                          GError              **error)
 {
 	g_return_val_if_fail (!stmt->stmt_is_sunk, NULL);
 
 	return tracker_db_cursor_sqlite_new (stmt->stmt, stmt, types, n_types);
 }
 
-
 static void
 tracker_db_statement_init (TrackerDBStatement *stmt)
 {



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