void CaptureData::AddDataElement( TargetHandle_t i_trgt, int i_scomId, const BitString * i_bs, Place i_place, RegType i_type ) { // Initial values of the bit string buffer if i_bs has a zero value. uint8_t * buf = nullptr; size_t sz_buf = 0; // Add buffer only if the value is non-zero. if ( !i_bs->isZero() ) { // Get the size of i_bs and ensure byte alignment. sz_buf = (i_bs->getBitLen() + 8-1) / 8; // Since we are using a BitString below, which does everything on a // CPU_WORD boundary, we must make sure the buffer is CPU_WORD aligned. const size_t sz_word = sizeof(CPU_WORD); sz_buf = ((sz_buf + sz_word-1) / sz_word) * sz_word; // Allocate memory for the buffer. buf = new uint8_t[sz_buf]; memset( buf, 0x00, sz_buf ); // Use a BitString to copy i_bs to the buffer. BitString bs ( i_bs->getBitLen(), (CPU_WORD *)buf ); bs.setString( *i_bs ); // Create the new data element. Data element( i_trgt, i_scomId, sz_buf, buf ); element.registerType = i_type; // Add the new element to the data. if ( FRONT == i_place ) data.insert( data.begin(), element ); else data.push_back( element ); } }