winstd::data_blob revised

This commit is contained in:
Simon Rozman 2016-06-22 23:32:20 +02:00
parent 0c8d8f8931
commit f9c0581409
2 changed files with 21 additions and 14 deletions

View File

@ -842,7 +842,7 @@ namespace winstd
/// ///
/// Initializes an empty BLOB. /// Initializes an empty BLOB.
/// ///
data_blob() inline data_blob()
{ {
cbData = 0; cbData = 0;
pbData = NULL; pbData = NULL;
@ -851,7 +851,7 @@ namespace winstd
/// ///
/// Initializes a BLOB from existing data. /// Initializes a BLOB from existing data.
/// ///
data_blob(_In_count_(size) BYTE *data, _In_ DWORD size) inline data_blob(_In_count_(size) BYTE *data, _In_ DWORD size)
{ {
cbData = size; cbData = size;
pbData = data; pbData = data;
@ -860,7 +860,7 @@ namespace winstd
/// ///
/// Duplicate an existing BLOB. /// Duplicate an existing BLOB.
/// ///
data_blob(_In_ const DATA_BLOB &other) inline data_blob(_In_ const DATA_BLOB &other)
{ {
cbData = other.cbData; cbData = other.cbData;
if (cbData) { if (cbData) {
@ -874,7 +874,7 @@ namespace winstd
/// ///
/// Move an existing BLOB. /// Move an existing BLOB.
/// ///
data_blob(_Inout_ DATA_BLOB &&other) inline data_blob(_Inout_ DATA_BLOB &&other)
{ {
cbData = other.cbData; cbData = other.cbData;
pbData = other.pbData; pbData = other.pbData;
@ -885,16 +885,12 @@ namespace winstd
/// ///
/// Destroys the BLOB. /// Destroys the BLOB.
/// ///
virtual ~data_blob() virtual ~data_blob();
{
if (pbData)
LocalFree(pbData);
}
/// ///
/// Copy an existing BLOB. /// Copy an existing BLOB.
/// ///
data_blob& operator=(_In_ const DATA_BLOB &other) inline data_blob& operator=(_In_ const DATA_BLOB &other)
{ {
if (this != &other) { if (this != &other) {
cbData = other.cbData; cbData = other.cbData;
@ -914,7 +910,7 @@ namespace winstd
/// ///
/// Move an existing BLOB. /// Move an existing BLOB.
/// ///
data_blob& operator=(_Inout_ DATA_BLOB &&other) inline data_blob& operator=(_Inout_ DATA_BLOB &&other)
{ {
if (this != &other) { if (this != &other) {
cbData = other.cbData; cbData = other.cbData;
@ -931,7 +927,7 @@ namespace winstd
/// ///
/// Get BLOB size. /// Get BLOB size.
/// ///
DWORD size() const inline DWORD size() const
{ {
return cbData; return cbData;
} }
@ -939,7 +935,7 @@ namespace winstd
/// ///
/// Get BLOB buffer. /// Get BLOB buffer.
/// ///
const BYTE* data() const inline const BYTE* data() const
{ {
return pbData; return pbData;
} }
@ -947,7 +943,7 @@ namespace winstd
/// ///
/// Get BLOB buffer. /// Get BLOB buffer.
/// ///
BYTE* data() inline BYTE* data()
{ {
return pbData; return pbData;
} }

View File

@ -149,3 +149,14 @@ winstd::crypt_key::handle_type winstd::crypt_key::duplicate_internal(_In_ handle
handle_type hNew = NULL; handle_type hNew = NULL;
return CryptDuplicateKey(h, NULL, 0, &hNew) ? hNew : NULL; return CryptDuplicateKey(h, NULL, 0, &hNew) ? hNew : NULL;
} }
//////////////////////////////////////////////////////////////////////
// winstd::data_blob
//////////////////////////////////////////////////////////////////////
winstd::data_blob::~data_blob()
{
if (pbData)
LocalFree(pbData);
}