[Galago-commits] r2317 - in trunk/libgalago: . libgalago
galago-commits at freedesktop.org
galago-commits at freedesktop.org
Tue Nov 15 19:58:13 PST 2005
Author: chipx86
Date: 2005-11-15 19:58:08 -0800 (Tue, 15 Nov 2005)
New Revision: 2317
Modified:
trunk/libgalago/ChangeLog
trunk/libgalago/libgalago/galago-account.c
trunk/libgalago/libgalago/galago-dbus.c
trunk/libgalago/libgalago/galago-person.c
trunk/libgalago/libgalago/galago-presence.c
trunk/libgalago/libgalago/galago-service.c
Log:
Use g_strdup_printf() instead of snprintf() when building object paths.
Modified: trunk/libgalago/ChangeLog
===================================================================
--- trunk/libgalago/ChangeLog 2005-11-15 18:43:13 UTC (rev 2316)
+++ trunk/libgalago/ChangeLog 2005-11-16 03:58:08 UTC (rev 2317)
@@ -1,3 +1,13 @@
+Tue Nov 15 19:57:04 PST 2005 Christian Hammond <chipx86 at chipx86.com>
+
+ * libgalago/galago-account.c:
+ * libgalago/galago-dbus.c:
+ * libgalago/galago-person.c:
+ * libgalago/galago-presence.c:
+ * libgalago/galago-service.c:
+ - Use g_strdup_printf() instead of snprintf() when building object
+ paths.
+
Sat Nov 12 15:56:58 PST 2005 Christian Hammond <chipx86 at chipx86.com>
* tests/get-avatar.c:
Modified: trunk/libgalago/libgalago/galago-account.c
===================================================================
--- trunk/libgalago/libgalago/galago-account.c 2005-11-15 18:43:13 UTC (rev 2316)
+++ trunk/libgalago/libgalago/galago-account.c 2005-11-16 03:58:08 UTC (rev 2317)
@@ -833,16 +833,8 @@
if (obj_prefix != NULL)
{
- size_t len;
- char *obj_path;
-
- len = strlen(obj_prefix) + strlen("/presence") + 1;
-
- obj_path = g_new(char, len);
- snprintf(obj_path, len, "%s/presence", obj_prefix);
-
+ char *obj_path = g_strdup_printf("%s/presence", obj_prefix);
galago_object_set_dbus_path(GALAGO_OBJECT(presence), obj_path);
-
g_free(obj_path);
}
Modified: trunk/libgalago/libgalago/galago-dbus.c
===================================================================
--- trunk/libgalago/libgalago/galago-dbus.c 2005-11-15 18:43:13 UTC (rev 2316)
+++ trunk/libgalago/libgalago/galago-dbus.c 2005-11-16 03:58:08 UTC (rev 2317)
@@ -731,7 +731,7 @@
if (!IS_VALID_DBUS_NAME_CHAR(*c))
{
char escaped_c[9];
- snprintf(escaped_c, sizeof(escaped_c), "_0x%x_", *c);
+ g_snprintf(escaped_c, sizeof(escaped_c), "_0x%x_", *c);
strncpy(d, escaped_c, BUFSIZ - (d - buffer));
d += strlen(escaped_c);
Modified: trunk/libgalago/libgalago/galago-person.c
===================================================================
--- trunk/libgalago/libgalago/galago-person.c 2005-11-15 18:43:13 UTC (rev 2316)
+++ trunk/libgalago/libgalago/galago-person.c 2005-11-16 03:58:08 UTC (rev 2317)
@@ -362,7 +362,6 @@
else if ((obj_prefix = galago_context_get_obj_path_prefix()) != NULL)
{
char *new_obj_path;
- size_t len;
const char *escaped_id;
if (!strcmp(id, GALAGO_ME_ID))
@@ -370,13 +369,9 @@
else
escaped_id = galago_dbus_normalize_name(id);
- len = strlen(obj_prefix) + strlen("/people/") +
- strlen(escaped_id) + 1;
+ new_obj_path = g_strdup_printf("%s/people/%s",
+ obj_prefix, escaped_id);
- new_obj_path = g_new(char, len);
- snprintf(new_obj_path, len, "%s/people/%s", obj_prefix,
- escaped_id);
-
galago_object_set_dbus_path(GALAGO_OBJECT(person), new_obj_path);
g_free(new_obj_path);
@@ -447,10 +442,10 @@
if (first_name != NULL || last_name != NULL)
{
- snprintf(buffer, sizeof(buffer), "%s%s%s",
- (first_name == NULL ? "" : first_name),
- (first_name != NULL && last_name != NULL ? " " : ""),
- (last_name == NULL ? "" : last_name));
+ g_snprintf(buffer, sizeof(buffer), "%s%s%s",
+ (first_name == NULL ? "" : first_name),
+ (first_name != NULL && last_name != NULL ? " " : ""),
+ (last_name == NULL ? "" : last_name));
return buffer;
}
Modified: trunk/libgalago/libgalago/galago-presence.c
===================================================================
--- trunk/libgalago/libgalago/galago-presence.c 2005-11-15 18:43:13 UTC (rev 2316)
+++ trunk/libgalago/libgalago/galago-presence.c 2005-11-16 03:58:08 UTC (rev 2317)
@@ -404,19 +404,9 @@
if (GALAGO_OBJECT_IS_LOCAL(person) && galago_is_connected())
{
- char *obj_path;
- size_t len;
-
- len = strlen(galago_object_get_dbus_path(GALAGO_OBJECT(presence))) +
- strlen(status_id) + 2;
-
- obj_path = g_new(char, len);
- snprintf(obj_path, len, "%s/%s",
- galago_object_get_dbus_path(GALAGO_OBJECT(presence)),
- status_id);
-
+ char *obj_path = g_strdup_printf("%s/%s",
+ galago_object_get_dbus_path(GALAGO_OBJECT(presence)), status_id);
galago_object_set_dbus_path(GALAGO_OBJECT(status), obj_path);
-
g_free(obj_path);
}
Modified: trunk/libgalago/libgalago/galago-service.c
===================================================================
--- trunk/libgalago/libgalago/galago-service.c 2005-11-15 18:43:13 UTC (rev 2316)
+++ trunk/libgalago/libgalago/galago-service.c 2005-11-16 03:58:08 UTC (rev 2317)
@@ -428,17 +428,10 @@
}
else if ((obj_prefix = galago_context_get_obj_path_prefix()) != NULL)
{
- size_t len;
- char *new_obj_path;
const char *escaped_id = galago_dbus_normalize_name(id);
+ char *new_obj_path = g_strdup_printf("%s/services/%s",
+ obj_prefix, escaped_id);
- len = strlen(obj_prefix) + strlen("/services/") +
- strlen(escaped_id) + 1;
-
- new_obj_path = g_new(char, len);
- snprintf(new_obj_path, len, "%s/services/%s", obj_prefix,
- escaped_id);
-
galago_object_set_dbus_path(GALAGO_OBJECT(service), new_obj_path);
g_free(new_obj_path);
@@ -524,19 +517,9 @@
if (obj_prefix != NULL)
{
- size_t len;
- char *obj_path;
- const char *escaped_username;
-
- escaped_username = galago_dbus_normalize_name(username);
-
- len = strlen(obj_prefix) + strlen(escaped_username) + 2;
-
- obj_path = g_new(char, len);
- snprintf(obj_path, len, "%s/%s", obj_prefix, escaped_username);
-
+ char *obj_path = g_strdup_printf("%s/%s", obj_prefix,
+ galago_dbus_normalize_name(username));
galago_object_set_dbus_path(GALAGO_OBJECT(account), obj_path);
-
g_free(obj_path);
}
More information about the galago-commits
mailing list