Fix an unimportant memory leak

This commit is contained in:
Přemysl Eric Janouch 2018-09-23 11:40:04 +02:00
parent 2efaed1a56
commit fcc0c3ef2d
Signed by: p
GPG Key ID: A0420B94F92B9493
1 changed files with 15 additions and 6 deletions

View File

@ -58,6 +58,15 @@ unichar_width (gunichar ch)
return 1 + g_unichar_iswide (ch); return 1 + g_unichar_iswide (ch);
} }
static guint
add_read_watch (int fd, GIOFunc func, gpointer user_data)
{
GIOChannel *channel = g_io_channel_unix_new (fd);
guint res = g_io_add_watch (channel, G_IO_IN, func, user_data);
g_io_channel_unref (channel);
return res;
}
// At times, GLib even with its sheer size is surprisingly useless, // At times, GLib even with its sheer size is surprisingly useless,
// and I need to port some code over from "liberty". // and I need to port some code over from "liberty".
@ -2083,8 +2092,8 @@ selection_watch_init (SelectionWatch *self, Application *app)
XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_CLIENT_CLOSE); XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_CLIENT_CLOSE);
(void) xcb_flush (self->X); (void) xcb_flush (self->X);
self->watch = g_io_add_watch (g_io_channel_unix_new self->watch = add_read_watch
(xcb_get_file_descriptor (self->X)), G_IO_IN, process_x11, self); (xcb_get_file_descriptor (self->X), process_x11, self);
// Never NULL so that we don't need to care about pointer validity // Never NULL so that we don't need to care about pointer validity
self->buffer = g_string_new (NULL); self->buffer = g_string_new (NULL);
@ -2291,10 +2300,10 @@ G_GNUC_END_IGNORE_DEPRECATIONS
// Message loop // Message loop
guint watch_term = g_unix_signal_add (SIGTERM, on_terminated, &app); guint watch_term = g_unix_signal_add (SIGTERM, on_terminated, &app);
guint watch_int = g_unix_signal_add (SIGINT, on_terminated, &app); guint watch_int = g_unix_signal_add (SIGINT, on_terminated, &app);
guint watch_stdin = g_io_add_watch (g_io_channel_unix_new (STDIN_FILENO), guint watch_stdin = add_read_watch
G_IO_IN, process_stdin_input, &app); (STDIN_FILENO, process_stdin_input, &app);
guint watch_winch = g_io_add_watch (g_io_channel_unix_new (g_winch_pipe[0]), guint watch_winch = add_read_watch
G_IO_IN, process_winch_input, &app); (g_winch_pipe[0], process_winch_input, &app);
#ifdef WITH_X11 #ifdef WITH_X11
SelectionWatch sw; SelectionWatch sw;