diff options
author | Cory Fields <cory-nospam-@coryfields.com> | 2023-07-06 18:35:13 +0000 |
---|---|---|
committer | Cory Fields <cory-nospam-@coryfields.com> | 2023-07-07 14:14:20 +0000 |
commit | b3582baa3a2f84db7d2fb5a681121a5f2d6de3a1 (patch) | |
tree | 8072b26822675fb8094cbfd95c5f08815948a1a1 /src/wallet/bdb.cpp | |
parent | e5e5aa1da261633c8f73b97d5aefe5dc450a7db9 (diff) | |
download | bitcoin-b3582baa3a2f84db7d2fb5a681121a5f2d6de3a1.tar.xz |
wallet: bdb: move SafeDbt to cpp file
Dbt requires including bdb headers.
Diffstat (limited to 'src/wallet/bdb.cpp')
-rw-r--r-- | src/wallet/bdb.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/wallet/bdb.cpp b/src/wallet/bdb.cpp index 4d410fa39e..26938e0a7d 100644 --- a/src/wallet/bdb.cpp +++ b/src/wallet/bdb.cpp @@ -232,6 +232,26 @@ BerkeleyEnvironment::BerkeleyEnvironment() : m_use_shared_memory(false) fMockDb = true; } +/** RAII class that automatically cleanses its data on destruction */ +class SafeDbt final +{ + Dbt m_dbt; + +public: + // construct Dbt with internally-managed data + SafeDbt(); + // construct Dbt with provided data + SafeDbt(void* data, size_t size); + ~SafeDbt(); + + // delegate to Dbt + const void* get_data() const; + uint32_t get_size() const; + + // conversion operator to access the underlying Dbt + operator Dbt*(); +}; + SafeDbt::SafeDbt() { m_dbt.set_flags(DB_DBT_MALLOC); |