Hello everyone

I've been lookking through the Geoclue code recently and came up with
some patches for it. The first is a simple patch to build with dbus <
1.0 by defining DBUS_API_SUBJECT_TO_CHANGE. The second patch optimises
the list loops in geoclue_master.c so that it doesn't have to walk the
list many times.

I also noticed the code seems to be a mix of indentation styles and uses
a lot of c++ style declarations/comments. I'm guessing the mix of
indentation is coming from some people indenting with spaces, others
with tabs. Would it be acceptable for me to go through and reindent it
all to tabs and fix the c++ declarations/comments? I'd have already done
it, but don't really want to if no-one wants it changed :)

iain
diff --git a/backend/position_hostip/geoclue_position_server_hostip.c b/backend/position_hostip/geoclue_position_server_hostip.c
index bd4eb48..e3d4967 100644
--- a/backend/position_hostip/geoclue_position_server_hostip.c
+++ b/backend/position_hostip/geoclue_position_server_hostip.c
@@ -23,6 +23,7 @@ #include "../common/geoclue_position_err
 #include <geoclue_position_server_glue.h>
 #include <geoclue_position_signal_marshal.h>
 
+#define DBUS_API_SUBJECT_TO_CHANGE
 #include <dbus/dbus-glib-bindings.h>
 #include <dbus/dbus.h>
 
diff --git a/backend/position_plazes/geoclue_position_server_plazes.c b/backend/position_plazes/geoclue_position_server_plazes.c
index 3d10b11..ea9052c 100644
--- a/backend/position_plazes/geoclue_position_server_plazes.c
+++ b/backend/position_plazes/geoclue_position_server_plazes.c
@@ -22,6 +22,7 @@ #include "../common/geoclue_position_err
 #include <geoclue_position_server_glue.h>
 #include <geoclue_position_signal_marshal.h>
 
+#define DBUS_API_SUBJECT_TO_CHANGE
 #include <dbus/dbus-glib-bindings.h>
 #include <dbus/dbus.h>
 
diff --git a/geoclue/geoclue_master.c b/geoclue/geoclue_master.c
index aa162af..cf7def7 100644
--- a/geoclue/geoclue_master.c
+++ b/geoclue/geoclue_master.c
@@ -218,14 +218,17 @@ gboolean geoclue_master_get_default_posi
 gboolean geoclue_master_get_all_position_providers (GeoclueMaster *obj, char *** OUT_service, char *** OUT_path, char *** OUT_description,  GError **error)
 {
     guint length =  g_list_length(obj->position_backends);
+    GList *l;
     *OUT_service        = malloc(length * sizeof(char*));
     *OUT_path           = malloc(length * sizeof(char*));
     *OUT_description    = malloc(length * sizeof(char*));    
     printf("length %d\n",length);
     int i;
-    for(i = 0; i < length; i++)
+
+    for(l = obj->position_backends, i = 0; l; l = l->next, i++)
     {
-        char** backend = g_list_nth_data(obj->position_backends, i);
+        char** backend = l->data;
+
         *OUT_service[i] = g_strdup(backend[0]);
         *OUT_path[i] = g_strdup(backend[1]);
         *OUT_description[i] = g_strdup(backend[3]);
@@ -261,14 +264,16 @@ gboolean geoclue_master_get_default_map_
 gboolean geoclue_master_get_all_map_providers (GeoclueMaster *obj, char *** OUT_service, char *** OUT_path, char *** OUT_description,  GError **error)
 {  
     guint length =  g_list_length(obj->map_backends);
+    GList *l;
     *OUT_service        = malloc(length * sizeof(char*));
     *OUT_path           = malloc(length * sizeof(char*));
     *OUT_description    = malloc(length * sizeof(char*));    
     printf("length %d\n",length);
     int i;
-    for(i = 0; i < length; i++)
-    {
-        char** backend = g_list_nth_data(obj->map_backends, i);
+
+    for(l = obj->map_backends, i = 0; l; l = l->next, i++) {
+        char** backend = l->data;
+
         *OUT_service[i] = g_strdup(backend[0]);
         *OUT_path[i] = g_strdup(backend[1]);
         *OUT_description[i] = g_strdup(backend[3]);
_______________________________________________
GeoClue mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/geoclue

Reply via email to