From 197f7cd4f744ae8246832343dc514296632554b2 Mon Sep 17 00:00:00 2001 From: lloyd Date: Tue, 7 Sep 2010 23:40:31 +0000 Subject: Big, invasive but mostly automated change, with a further attempt at harmonising MemoryRegion with std::vector: The MemoryRegion::clear() function would zeroise the buffer, but keep the memory allocated and the size unchanged. This is very different from STL's clear(), which is basically the equivalent to what is called destroy() in MemoryRegion. So to be able to replace MemoryRegion with a std::vector, we have to rename destroy() to clear() and we have to expose the current functionality of clear() in some other way, since vector doesn't support this operation. Do so by adding a global function named zeroise() which takes a MemoryRegion which is zeroed. Remove clear() to ensure all callers are updated. --- src/asn1/ber_dec.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/asn1/ber_dec.cpp') diff --git a/src/asn1/ber_dec.cpp b/src/asn1/ber_dec.cpp index ea0334202..1c0d218ca 100644 --- a/src/asn1/ber_dec.cpp +++ b/src/asn1/ber_dec.cpp @@ -451,7 +451,9 @@ BER_Decoder& BER_Decoder::decode(MemoryRegion& buffer, { if(obj.value[0] >= 8) throw BER_Decoding_Error("Bad number of unused bits in BIT STRING"); - buffer.set(obj.value + 1, obj.value.size() - 1); + + buffer.resize(obj.value.size() - 1); + copy_mem(&buffer[0], &obj.value[1], obj.value.size() - 1); } return (*this); } @@ -467,7 +469,7 @@ BER_Decoder& BER_Decoder::decode_optional_string(MemoryRegion& out, ASN1_Tag type_tag = static_cast(type_no); - out.clear(); + out.destroy(); push_back(obj); if(obj.type_tag == type_tag && obj.class_tag == CONTEXT_SPECIFIC) -- cgit v1.2.3