[mutter] x11-selection: Don't store copies of strings that are not being used
- From: Robert Mader <rmader src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] x11-selection: Don't store copies of strings that are not being used
- Date: Sat, 1 Feb 2020 14:31:58 +0000 (UTC)
commit c05019e2328948f39e45870f5a33ad6be478e231
Author: Sebastian Keller <skeller src gnome org>
Date: Sat Jan 11 04:21:26 2020 +0100
x11-selection: Don't store copies of strings that are not being used
MetaX11SelectionOutputStream was storing copies of strings only to use
them in init and then free them in finalize. This was also causing a
small leak, because one of these strings was not freed. Instead of doing
that just don't create these unnecessary copies in the first place.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1001
src/x11/meta-x11-selection-output-stream.c | 20 ++++----------------
1 file changed, 4 insertions(+), 16 deletions(-)
---
diff --git a/src/x11/meta-x11-selection-output-stream.c b/src/x11/meta-x11-selection-output-stream.c
index 86615364a..1883bc92a 100644
--- a/src/x11/meta-x11-selection-output-stream.c
+++ b/src/x11/meta-x11-selection-output-stream.c
@@ -37,13 +37,9 @@ struct _MetaX11SelectionOutputStreamPrivate
{
MetaX11Display *x11_display;
Window xwindow;
- char *selection;
Atom xselection;
- char *target;
Atom xtarget;
- char *property;
Atom xproperty;
- const char *type;
Atom xtype;
int format;
gulong timestamp;
@@ -515,10 +511,6 @@ meta_x11_selection_output_stream_finalize (GObject *object)
g_cond_clear (&priv->cond);
g_mutex_clear (&priv->mutex);
- g_free (priv->selection);
- g_free (priv->target);
- g_free (priv->property);
-
G_OBJECT_CLASS (meta_x11_selection_output_stream_parent_class)->finalize (object);
}
@@ -606,14 +598,10 @@ meta_x11_selection_output_stream_new (MetaX11Display *x11_display,
priv->x11_display = x11_display;
priv->xwindow = requestor;
- priv->selection = g_strdup (selection);
- priv->xselection = XInternAtom (x11_display->xdisplay, priv->selection, False);
- priv->target = g_strdup (target);
- priv->xtarget = XInternAtom (x11_display->xdisplay, priv->target, False);
- priv->property = g_strdup (property);
- priv->xproperty = XInternAtom (x11_display->xdisplay, priv->property, False);
- priv->type = g_strdup (type);
- priv->xtype = XInternAtom (x11_display->xdisplay, priv->type, False);
+ priv->xselection = XInternAtom (x11_display->xdisplay, selection, False);
+ priv->xtarget = XInternAtom (x11_display->xdisplay, target, False);
+ priv->xproperty = XInternAtom (x11_display->xdisplay, property, False);
+ priv->xtype = XInternAtom (x11_display->xdisplay, type, False);
priv->format = format;
priv->timestamp = timestamp;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]