gmain: Add g_steal_fd() to API

This is basically glnx_steal_fd() from libglnx. We already had two
private implementations of it in GLib.

Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
Simon McVittie
2021-03-22 11:48:10 +00:00
committed by Philip Withnall
parent 46c34ea20f
commit 6c5a227bcc
6 changed files with 69 additions and 23 deletions

View File

@@ -781,6 +781,15 @@ void g_main_context_invoke (GMainContext *context,
GSourceFunc function,
gpointer data);
GLIB_AVAILABLE_STATIC_INLINE_IN_2_70
static inline int
g_steal_fd (int *fd_ptr)
{
int fd = *fd_ptr;
*fd_ptr = -1;
return fd;
}
/* Hook for GClosure / GSource integration. Don't touch */
GLIB_VAR GSourceFuncs g_timeout_funcs;
GLIB_VAR GSourceFuncs g_child_watch_funcs;