[gdm] display: Don't strdup unnecessarily
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdm] display: Don't strdup unnecessarily
- Date: Sat, 15 Feb 2014 03:02:13 +0000 (UTC)
commit 0ac1718e22cd5cfc34df209a6300d9bd73f2015f
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Fri Feb 14 21:48:50 2014 -0500
display: Don't strdup unnecessarily
We can simply return a const char * here.
daemon/gdm-display.c | 4 ++--
daemon/gdm-display.h | 2 +-
daemon/gdm-manager.c | 10 ++--------
3 files changed, 5 insertions(+), 11 deletions(-)
---
diff --git a/daemon/gdm-display.c b/daemon/gdm-display.c
index 67ebac8..3251bc3 100644
--- a/daemon/gdm-display.c
+++ b/daemon/gdm-display.c
@@ -134,10 +134,10 @@ gdm_display_get_status (GdmDisplay *display)
return display->priv->status;
}
-char *
+const char *
gdm_display_get_session_id (GdmDisplay *display)
{
- return g_strdup (display->priv->session_id);
+ return display->priv->session_id;
}
static GdmDisplayAccessFile *
diff --git a/daemon/gdm-display.h b/daemon/gdm-display.h
index bfba143..739be7d 100644
--- a/daemon/gdm-display.h
+++ b/daemon/gdm-display.h
@@ -102,7 +102,7 @@ char * gdm_display_open_reauthentication_channel_sync (GdmDi
uid_t uid_of_caller,
GCancellable *cancellable,
GError **error);
-char * gdm_display_get_session_id (GdmDisplay *display);
+const char * gdm_display_get_session_id (GdmDisplay *display);
gboolean gdm_display_create_authority (GdmDisplay *display);
gboolean gdm_display_prepare (GdmDisplay *display);
gboolean gdm_display_manage (GdmDisplay *display);
diff --git a/daemon/gdm-manager.c b/daemon/gdm-manager.c
index be2c267..b1c61c2 100644
--- a/daemon/gdm-manager.c
+++ b/daemon/gdm-manager.c
@@ -260,16 +260,10 @@ lookup_by_session_id (const char *id,
gpointer user_data)
{
const char *looking_for = user_data;
- char *current;
- gboolean res;
+ const char *current;
current = gdm_display_get_session_id (display);
-
- res = g_strcmp0 (current, looking_for) == 0;
-
- g_free (current);
-
- return res;
+ return g_strcmp0 (current, looking_for) == 0;
}
static GdmDisplay *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]