diff options
Diffstat (limited to 'libcpp/include/line-map.h')
-rw-r--r-- | libcpp/include/line-map.h | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h index c434a24..9bdd5b9 100644 --- a/libcpp/include/line-map.h +++ b/libcpp/include/line-map.h @@ -1851,7 +1851,7 @@ public: label_text (label_text &&other) : m_buffer (other.m_buffer), m_owned (other.m_owned) { - other.moved_from (); + other.release (); } /* Move assignment. */ @@ -1861,7 +1861,7 @@ public: free (m_buffer); m_buffer = other.m_buffer; m_owned = other.m_owned; - other.moved_from (); + other.release (); return *this; } @@ -1882,25 +1882,26 @@ public: return label_text (buffer, true); } - /* Take ownership of the buffer, copying if necessary. */ - char *take_or_copy () + void release () { - if (m_owned) - return m_buffer; - else - return xstrdup (m_buffer); + m_buffer = NULL; + m_owned = false; } - void moved_from () + const char *get () const { - m_buffer = NULL; - m_owned = false; + return m_buffer; } + bool is_owner () const + { + return m_owned; + } + +private: char *m_buffer; bool m_owned; -private: label_text (char *buffer, bool owned) : m_buffer (buffer), m_owned (owned) {} |