- SizeType* srcData = reinterpret_cast< SizeType* >( vector.mData );
- SizeType* dstData = reinterpret_cast< SizeType* >( mData );
- memcpy( dstData - 2u, srcData - 2u, wholeAllocation );
+ void* wholeData = reinterpret_cast<void*>(new uint8_t[wholeAllocation]);
+ DALI_ASSERT_ALWAYS(wholeData && "VectorBase::Copy - Memory allocation failed");
+
+ // copy over whole data
+ SizeType* srcData = reinterpret_cast<SizeType*>(vector.mData);
+ SizeType* dstData = reinterpret_cast<SizeType*>(wholeData) + 2u;
+ memcpy(dstData - 2u, srcData - 2u, wholeAllocation);
+
+ // release old buffer and set new data as mData
+ Replace(reinterpret_cast<void*>(dstData));