service: Use helper function to add timeservers only once
authorPatrik Flykt <patrik.flykt@linux.intel.com>
Mon, 30 Apr 2012 11:13:01 +0000 (14:13 +0300)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 1 May 2012 04:08:49 +0000 (06:08 +0200)
src/service.c

index a6bd606..018f12f 100644 (file)
@@ -2968,10 +2968,15 @@ static DBusMessage *set_property(DBusConnection *conn,
 
                while (dbus_message_iter_get_arg_type(&entry) == DBUS_TYPE_STRING) {
                        const char *val;
+                       GSList *new_head;
+
                        dbus_message_iter_get_basic(&entry, &val);
 
-                       list = g_slist_prepend(list, strdup(val));
-                       count++;
+                       new_head = __connman_timeserver_add_list(list, val);
+                       if (list != new_head) {
+                               count++;
+                               list = new_head;
+                       }
 
                        dbus_message_iter_next(&entry);
                }