diff options
author | Simon McVittie <smcv@collabora.com> | 2021-02-25 10:33:09 +0000 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2021-03-21 17:17:23 +0000 |
commit | 7f10bcc1b84e9ed6496569de741e84ff0e0a673c (patch) | |
tree | 4c2bf28d0d11f868e8ca87811b69998ecb182911 /glib/gfileutils.c | |
parent | 46c34ea20fc020cde5d07c69747a5d4d12197e96 (diff) | |
download | glib-wip/steal-fd.tar.gz |
gmain: Add g_steal_fd() to APIwip/steal-fd
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>
Diffstat (limited to 'glib/gfileutils.c')
-rw-r--r-- | glib/gfileutils.c | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/glib/gfileutils.c b/glib/gfileutils.c index a4e90265e..e0a2a65d0 100644 --- a/glib/gfileutils.c +++ b/glib/gfileutils.c @@ -1208,14 +1208,6 @@ write_to_file (const gchar *contents, return TRUE; } -static inline int -steal_fd (int *fd_ptr) -{ - int fd = *fd_ptr; - *fd_ptr = -1; - return fd; -} - /** * g_file_set_contents: * @filename: (type filename): name of a file to write @contents to, in the GLib file name @@ -1369,7 +1361,7 @@ g_file_set_contents_full (const gchar *filename, } do_fsync = fd_should_be_fsynced (fd, filename, flags); - if (!write_to_file (contents, length, steal_fd (&fd), tmp_filename, do_fsync, error)) + if (!write_to_file (contents, length, g_steal_fd (&fd), tmp_filename, do_fsync, error)) { g_unlink (tmp_filename); retval = FALSE; @@ -1479,7 +1471,7 @@ consistent_out: } do_fsync = fd_should_be_fsynced (direct_fd, filename, flags); - if (!write_to_file (contents, length, steal_fd (&direct_fd), filename, + if (!write_to_file (contents, length, g_steal_fd (&direct_fd), filename, do_fsync, error)) return FALSE; } |