[libglnx] Add glnx_steal_fd
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libglnx] Add glnx_steal_fd
- Date: Fri, 11 Dec 2015 15:22:21 +0000 (UTC)
commit 4e9969998b3d385fc007fa5deba5f256aa7b2e95
Author: Alexander Larsson <alexl redhat com>
Date: Fri Dec 11 15:56:06 2015 +0100
Add glnx_steal_fd
This is very useful in combination with glnx_close_fd
https://bugzilla.gnome.org/show_bug.cgi?id=757611
glnx-local-alloc.h | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/glnx-local-alloc.h b/glnx-local-alloc.h
index a193e60..af5af4b 100644
--- a/glnx-local-alloc.h
+++ b/glnx-local-alloc.h
@@ -211,4 +211,12 @@ glnx_cleanup_close_fdp (int *fdp)
*/
#define glnx_fd_close __attribute__((cleanup(glnx_cleanup_close_fdp)))
+static inline int
+glnx_steal_fd (int *fdp)
+{
+ int fd = *fdp;
+ *fdp = -1;
+ return fd;
+}
+
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]