diff options
author | Rainer Keller <Rainer.Keller@qt.io> | 2019-03-06 10:26:05 +0100 |
---|---|---|
committer | Rainer Keller <Rainer.Keller@qt.io> | 2019-03-06 15:34:42 +0000 |
commit | dee609343270c17b9ff132860eda822eb01028ed (patch) | |
tree | 2fe5bb100c7990103e3ac4bdb6cf200bea5b8f52 | |
parent | e93c6d13952831a74f2376b8a6369c0b7cd10d26 (diff) |
open62541: Add option to skip deletion of data structures
This is useful, if the deleter should only be active in case of error
returns. When a function returns successfully the data should not be
deleted.
Change-Id: I9da57fa242bbe4346ea5f11d5793f02e78f8b9a5
Reviewed-by: Jannis Völker <jannis.voelker@basyskom.com>
Reviewed-by: Frank Meerkoetter <frank.meerkoetter@basyskom.com>
-rw-r--r-- | src/plugins/opcua/open62541/qopen62541utils.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/plugins/opcua/open62541/qopen62541utils.h b/src/plugins/opcua/open62541/qopen62541utils.h index 5a40c6c..fd13219 100644 --- a/src/plugins/opcua/open62541/qopen62541utils.h +++ b/src/plugins/opcua/open62541/qopen62541utils.h @@ -59,6 +59,11 @@ public: if (m_data) m_function(m_data); } + void release() + { + m_data = nullptr; + m_function = nullptr; + } private: T *m_data {nullptr}; std::function<void(T *attribute)> m_function; @@ -79,6 +84,10 @@ public: if (m_data && m_arrayLength > 0) UA_Array_delete(m_data, m_arrayLength, &UA_TYPES[TYPEINDEX]); } + void release() { + m_data = nullptr; + m_arrayLength = 0; + } private: void *m_data {nullptr}; size_t m_arrayLength {0}; |