diff -r 62a1d3631dcb -r b1b049e28772 MiniDisplay/BitArray.cpp --- a/MiniDisplay/BitArray.cpp Tue May 27 22:14:29 2014 +0200 +++ b/MiniDisplay/BitArray.cpp Wed May 28 08:06:27 2014 +0200 @@ -124,7 +124,9 @@ * Returned : None ***************************************************************************/ BitArray::BitArray(const int numBits): - m_NumBits(numBits) + m_NumBits(numBits), + m_Array(NULL), + m_OwnsBuffer(true) { m_SizeInBytes = BITS_TO_CHARS(numBits); @@ -146,10 +148,12 @@ * Effects : Allocates vectory for array bits * Returned : None ***************************************************************************/ -BitArray::BitArray(unsigned char *array, const int numBits): +BitArray::BitArray(unsigned char *array, const int numBits,bool aOwnsBuffer): m_NumBits(numBits), - m_Array(array) + m_Array(array), + m_OwnsBuffer(aOwnsBuffer) { + } /*************************************************************************** @@ -162,7 +166,11 @@ ***************************************************************************/ BitArray::~BitArray(void) { - delete[] m_Array; + if (m_OwnsBuffer) + { + delete[] m_Array; + m_Array = NULL; + } } /***************************************************************************