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
This commit is contained in:
Sebastian Keller 2020-01-11 04:21:26 +01:00 committed by Robert Mader
parent 861e5caf8c
commit c05019e232

View File

@ -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;