[vte] lib: Improve smart_fd
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte] lib: Improve smart_fd
- Date: Thu, 14 Jan 2016 16:10:04 +0000 (UTC)
commit 5680acc70fb10640ae32ee8be936cec1147dec9f
Author: Christian Persch <chpe gnome org>
Date: Thu Jan 14 17:05:33 2016 +0100
lib: Improve smart_fd
src/vtetypes.hh | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
---
diff --git a/src/vtetypes.hh b/src/vtetypes.hh
index eff2743..7d610f6 100644
--- a/src/vtetypes.hh
+++ b/src/vtetypes.hh
@@ -187,7 +187,7 @@ namespace util {
~smart_fd() { if (m_fd != -1) { restore_errno errsv; close(m_fd); } }
inline smart_fd& operator = (int rhs) { if (m_fd != -1) { restore_errno errsv; close(m_fd);
} m_fd = rhs; return *this; }
- inline smart_fd& operator = (smart_fd& rhs) { if (&rhs != this) { m_fd = rhs.m_fd; rhs.m_fd
= -1; } return *this; }
+ inline smart_fd& operator = (smart_fd& rhs) { if (&rhs != this) { if (m_fd != -1) {
restore_errno errsv; close(m_fd); } m_fd = rhs.m_fd; rhs.m_fd = -1; } return *this; }
inline operator int () const { return m_fd; }
inline operator int* () { g_assert(m_fd == -1); return &m_fd; }
@@ -195,7 +195,9 @@ namespace util {
/* Prevent accidents */
smart_fd(smart_fd const&) = delete;
+ smart_fd(smart_fd&&) = delete;
smart_fd& operator = (smart_fd const&) = delete;
+ smart_fd& operator = (smart_fd&&) = delete;
private:
int m_fd;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]