本文整理汇总了C++中MemCopy函数的典型用法代码示例。如果您正苦于以下问题:C++ MemCopy函数的具体用法?C++ MemCopy怎么用?C++ MemCopy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MemCopy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Unimplemented2
u32 mxRenderMesh::CopyFromMesh( const ::irr::scene::IMesh* mesh )
{
if ( mesh->getMeshBufferCount() > 0 )
{
if ( mesh->getMeshBufferCount() > 1 ) {
Unimplemented2( "multiple mesh buffers" );
}
::irr::scene::IMeshBuffer * pBuf = mesh->getMeshBuffer( 0 );
Assert( pBuf );
Assert2( pBuf->getIndexType() == ::irr::video::E_INDEX_TYPE::EIT_16BIT, "only 16-bit indices are supported !" );
Assert2( pBuf->getVertexType() == ::irr::video::E_VERTEX_TYPE::EVT_STANDARD, "only standard vertex type is supported !" );
const TVertex * pVertices = ( TVertex* ) pBuf->getVertices();
const u32 vertexCount = pBuf->getVertexCount();
Vertices.SetNum( vertexCount );
MemCopy( Vertices.Ptr(), pVertices, vertexCount * sizeof( TVertex ) );
const TIndex * pIndices = pBuf->getIndices();
const u32 triangleCount = pBuf->getIndexCount() / 3;
Triangles.SetNum( triangleCount );
MemCopy( Triangles.Ptr(), pIndices, pBuf->getIndexCount() * sizeof( TIndex ) );
// GCommon->DebugPrint( "* Loaded mesh: %u verts, %u tris\n", vertexCount, triangleCount );
return triangleCount;
}
return 0;
}
示例2: StartReceiveImages
void StartReceiveImages()
{
uint16_t rowReceived = 0;
uint16_t bytesInRowReceived = 0;
uint16_t const bytesInARow = 720;
while (true)
{
RefreshButtonState(&leftButton, NULL);
RefreshButtonState(&rightButton, NULL);
RefreshLEDState(false, LED_MAX_BRIGHTNESS);
if (NRF24L01_DataReady())
{
NRF24L01_GetData(dataIn);
if (!mem_cmp(startCommand, dataIn, 32))
{
RefreshLEDState(true, LED_MAX_BRIGHTNESS);
Delay_ms(50);
_receivingImage = 1;
rowReceived = 0;
bytesInRowReceived = 0;
LCDInitializeDataSend();
continue;
}
if (_receivingImage)
{
MemCopy(dataIn, rowData, 0, bytesInRowReceived, 32);
bytesInRowReceived += 32;
if (bytesInRowReceived >= bytesInARow)
{
LCDFillRow(rowData);
bytesInRowReceived = bytesInRowReceived - bytesInARow;
MemCopy(dataIn, rowData, bytesInRowReceived, 0, bytesInRowReceived);
rowReceived++;
if (rowReceived == 320)
{
RefreshLEDState(false, LED_MAX_BRIGHTNESS);
_receivingImage = 0;
rowReceived = 0;
bytesInRowReceived = 0;
LCDFinishDataSend();
}
}
}
}
}
}
示例3: MemCopy
HTREEITEM CTreeCtrl::FindItem(LPCSTR pText,BOOL bBackwardDirection,BOOL bPartial,HTREEITEM hItem,HTREEITEM hEnd) const
{
TV_ITEMA ti;
char szBuffer[1000];
ti.mask=TVIF_TEXT;
ti.hItem=hItem;
ti.pszText=szBuffer;
ti.cchTextMax=1000;
LPSTR pTextMod;
if (bPartial)
{
int iStrLen=istrlen(pText);
pTextMod=new char[iStrLen+3];
if (pText[0]!='*')
{
pTextMod[0]='*';
MemCopy(pTextMod+1,pText,iStrLen++);
}
else
MemCopy(pTextMod,pText,iStrLen);
if (pTextMod[iStrLen-1]!='*')
pTextMod[iStrLen++]='*';
pTextMod[iStrLen]='\0';
MakeLower(pTextMod);
}
while ((ti.hItem=bBackwardDirection?GetPrevItem(ti.hItem):GetNextItem(ti.hItem))!=NULL)
{
// Get next item
if (ti.hItem==hEnd)
return NULL;
// Check text
if (!GetItem(&ti))
continue;
if (bPartial)
{
MakeLower(szBuffer);
if (ContainString(szBuffer,pTextMod))
{
delete[] pTextMod;
return ti.hItem;
}
}
else if (_stricmp(szBuffer,pText)==0)
return ti.hItem;
}
if (bPartial)
delete[] pTextMod;
return NULL;
}
示例4: main
void main(void)
{
InitSysCtrl();
// Copy time critical code and Flash setup code to RAM
// This includes the following ISR functions: epwm1_timer_isr(), epwm2_timer_isr()
// epwm3_timer_isr and and InitFlash();
// The RamfuncsLoadStart, RamfuncsLoadEnd, and RamfuncsRunStart
// symbols are created by the linker. Refer to the F28335.cmd file.
// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
DINT;
// Initialize the PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
// This function is found in the DSP2833x_PieCtrl.c file.
InitPieCtrl();
// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
// This will populate the entire table, even if the interrupt
// is not used in this example. This is useful for debug purposes.
// The shell ISR routines are found in DSP2833x_DefaultIsr.c.
// This function is found in DSP2833x_PieVect.c.
InitPieVectTable();
// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.SEQ1INT = &PWM_AD_isr;
PieVectTable.ECAN0INTA = &Skiip4_CAN_isr;
EDIS; // This is needed to disable write to EALLOW protected registers
InitFlash();
MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);
MemCopy(&IQmathLoadStart, &IQmathLoadEnd, &IQmathRunStart);
//ECan-A模块初始化
InitECan();
InitECan1();
InitGpio(); // Skipped for this example
InitAdc(); // Initialize necessary ADC module, directly for SVPWM.
InitEPwm();
IER |= M_INT1;
// Enable SEQ1_INT which is connected to PIE1.1:
IER |= M_INT9;
// Enable eCAN0-A INT which is connected to PIE9.5:
EINT;
} // end of main()
示例5: MemSwap
inline void
MemSwap( T* a, T* b, T* temp, size_t numEntries )
{
// temp := a
MemCopy( temp, a, numEntries );
// a := b
MemCopy( a, b, numEntries );
// b := temp
MemCopy( b, temp, numEntries );
}
示例6: entry
const DistMatrix<T,STAR,STAR>&
DistMatrix<T,STAR,STAR>::operator=( const DistMatrix<T,STAR,VR>& A )
{
#ifndef RELEASE
CallStackEntry entry("[* ,* ] = [* ,VR]");
this->AssertNotLocked();
this->AssertSameGrid( A.Grid() );
#endif
const elem::Grid& g = this->Grid();
this->ResizeTo( A.Height(), A.Width() );
if( !this->Participating() )
return *this;
const Int p = g.Size();
const Int height = this->Height();
const Int width = this->Width();
const Int localWidthOfA = A.LocalWidth();
const Int maxLocalWidth = MaxLength(width,p);
const Int portionSize = mpi::Pad( height*maxLocalWidth );
T* buffer = this->auxMemory_.Require( (p+1)*portionSize );
T* sendBuf = &buffer[0];
T* recvBuf = &buffer[portionSize];
// Pack
const Int ALDim = A.LDim();
const T* ABuf = A.LockedBuffer();
PARALLEL_FOR
for( Int jLoc=0; jLoc<localWidthOfA; ++jLoc )
MemCopy( &sendBuf[jLoc*height], &ABuf[jLoc*ALDim], height );
// Communicate
mpi::AllGather
( sendBuf, portionSize,
recvBuf, portionSize, g.VRComm() );
// Unpack
T* thisBuf = this->Buffer();
const Int thisLDim = this->LDim();
const Int rowAlignmentOfA = A.RowAlignment();
OUTER_PARALLEL_FOR
for( Int k=0; k<p; ++k )
{
const T* data = &recvBuf[k*portionSize];
const Int rowShift = Shift_( k, rowAlignmentOfA, p );
const Int localWidth = Length_( width, rowShift, p );
INNER_PARALLEL_FOR
for( Int jLoc=0; jLoc<localWidth; ++jLoc )
MemCopy
( &thisBuf[(rowShift+jLoc*p)*thisLDim],
&data[jLoc*height], height );
}
this->auxMemory_.Release();
return *this;
}
示例7: WriteNewLineObject
/***************************************************************************
*
* Function to put the string into the buffer
*
***************************************************************************/
SINT WriteNewLineObject(MEMPTR lpMem, MEMPTR Obj)
{
SINT Res1, Res2;
Res1 = lstrlen(NewLine);
MemCopy(lpMem, NewLine, Res1);
lpMem += Res1;
Res2 = lstrlen(Obj);
MemCopy(lpMem, Obj, Res2);
return( Res1 + Res2 );
}
示例8: AsnLexReadOctets
/*****************************************************************************
*
* ByteStorePtr AsnLexReadOctets(aip, atp)
* expects Octets type next
* assumes none of it has already been read
* does not advance to next token
* atp points to the definition of this OCTET STRING
*
*****************************************************************************/
NLM_EXTERN ByteStorePtr AsnLexReadOctets (AsnIoPtr aip, AsnTypePtr atp)
{
Int2 token, len;
ByteStorePtr ssp = NULL;
Byte tbuf[256]; /* was 101 - changed to handle occasional hand-edited ASN.1? */
Int4 bytes, left, added;
token = AsnLexWord(aip); /* read the start */
if (token != START_BITHEX)
{
AsnIoErrorMsg(aip, 45, AsnErrGetTypeName(atp->name), aip->linenumber);
return NULL;
}
ssp = BSNew(0);
if (ssp == NULL) return ssp;
token = AsnLexWord(aip); /* read the octet(s) */
left = 0;
while (token == IN_BITHEX)
{
len = (Int2)(aip->wordlen + left);
MemCopy((tbuf + left), aip->word, (len - left));
tbuf[len] = '\0';
added = AsnTypeStringToHex(tbuf, len, tbuf, &left);
if (added < 0)
{
AsnIoErrorMsg(aip, 46, AsnErrGetTypeName(atp->name), aip->linenumber);
return NULL;
}
if (added)
{
bytes = BSWrite(ssp, tbuf, added);
if (bytes != added)
{
ssp = BSFree(ssp);
return ssp;
}
}
if (left) /* left a char */
{
MemCopy(tbuf, ((aip->word)+(aip->wordlen - left)),left);
}
token = AsnLexWord(aip);
}
if (token != OCTETS)
{
AsnIoErrorMsg(aip, 47, AsnErrGetTypeName(atp->name), aip->linenumber);
return NULL;
}
return ssp;
}
示例9: BlendFill
inline void BlendFill(
NormalPixel color,
GenericPixelPtr<DstPixelType> d_line,
const unsigned char *a_line,
int a_pitch,
int w,
int h,
bool inverted,
int alpha_0,
int alpha_1 )
{
size_t line_size = w * sizeof(DstPixelType);
MemBlock d_cache( line_size );
while ( h-- )
{
MemCopy( d_cache.GetPtr(), (DstPixelType*)d_line, line_size );
DstPixelType *d_ptr = (DstPixelType*)d_cache.GetPtr();
const unsigned char *a_ptr = a_line;
if ( alpha_0>0 || alpha_1<256 )
{
if (!inverted)
for ( int i=w; i--; ++a_ptr, ++d_ptr )
{
BlendPixel( *d_ptr, color, *a_ptr *(alpha_1-alpha_0)/256+alpha_0 );
}
else
for ( int i=w; i--; ++a_ptr, ++d_ptr )
{
BlendPixel( *d_ptr, color, (255-*a_ptr) *(alpha_1-alpha_0)/256+alpha_0 );
}
}
else if (!inverted)
for ( int i=w; i--; ++a_ptr, ++d_ptr )
{
BlendPixel( *d_ptr, color, *a_ptr );
}
else
for ( int i=w; i--; ++a_ptr, ++d_ptr )
{
BlendPixel( *d_ptr, color, 255-*a_ptr );
}
MemCopy( (DstPixelType*)d_line, d_cache.GetPtr(), line_size );
d_line.Next();
a_line += a_pitch;
}
}
示例10: buffer
static void Func
( DistMatrix<T,STAR,MR>& A, T center, typename Base<T>::type radius )
{
const Grid& grid = A.Grid();
const int m = A.Height();
const int localWidth = A.LocalWidth();
const int bufSize = m*localWidth;
std::vector<T> buffer( bufSize );
// Create random matrix on process row 0, then broadcast
if( grid.Row() == 0 )
{
for( int j=0; j<localWidth; ++j )
for( int i=0; i<m; ++i )
buffer[i+j*m] = center+radius*SampleUnitBall<T>();
}
mpi::Broadcast( &buffer[0], bufSize, 0, grid.ColComm() );
// Unpack
T* localBuffer = A.LocalBuffer();
const int ldim = A.LocalLDim();
#ifdef HAVE_OPENMP
#pragma omp parallel for
#endif
for( int jLocal=0; jLocal<localWidth; ++jLocal )
{
const T* bufferCol = &buffer[jLocal*m];
T* col = &localBuffer[jLocal*ldim];
MemCopy( col, bufferCol, m );
}
}
示例11: PrintNextImage
void PrintNextImage(volatile void *uselessParameter)
{
_receivingImage = 0;
if (previousFileIsValid)
{
uint16_t stringLength = strlen(fno.fname) + 1;
MemCopy(fno.fname, previousFileName, 0, 0, stringLength);
}
FRESULT res;
res = pf_readdir(&dir, &fno);
if (res == FR_NO_FILE)
{
char *rootDir = " ";
pf_opendir(&dir, rootDir);
res = pf_readdir(&dir, &fno);
if (res == FR_NO_FILE)
{
return;
}
}
if (!CheckBMPImage(fno.fname))
{
previousFileIsValid = true;
PrintImage(fno.fname);
}
}
示例12: allocstringW
LPWSTR allocstringW(UINT nID,TypeOfResourceHandle bType)
{
LPWSTR szBuffer;
szBuffer=new WCHAR[STR_LOADSTRINGBUFLEN];
if (szBuffer==NULL)
{
SetHFCError(HFC_CANNOTALLOCATE);
return NULL;
}
UINT nDataLen=::LoadString(nID,szBuffer,STR_LOADSTRINGBUFLEN,bType);
if (nDataLen>=STR_LOADSTRINGBUFLEN-2)
{
for (DWORD i=2;nDataLen>=i*STR_LOADSTRINGBUFLEN-2;i++)
{
delete[] szBuffer;
szBuffer=new WCHAR[i*STR_LOADSTRINGBUFLEN];
nDataLen=::LoadString(nID,szBuffer,i*STR_LOADSTRINGBUFLEN,bType);
}
}
WCHAR* pText=new WCHAR[nDataLen+1];
MemCopy(pText,szBuffer,(nDataLen+1)*2);
delete[] szBuffer;
return pText;
}
示例13: MergeIDATs
/* Collapse multiple IDAT chunks into single one. */
static void MergeIDATs(PngT *png) {
if (png->idat.next) {
uint32_t length, i;
uint8_t *data;
IdatT *idat;
for (idat = &png->idat, length = 0; idat; idat = idat->next)
length += idat->length;
LOG("Merged chunk length: %d.", length);
data = MemNew(length);
for (idat = &png->idat, i = 0; idat;) {
IdatT *next = idat->next;
MemCopy(data + i, idat->data, idat->length);
i += idat->length;
MemUnref(idat->data);
if (idat != &png->idat)
MemUnref(idat);
idat = next;
}
png->idat.data = data;
png->idat.length = length;
png->idat.next = NULL;
}
}
示例14: GapSetReconnectionAddress
extern void GapSetReconnectionAddress(uint8 *p_val)
{
if(p_val == NULL)
{
MAKE_RECONNECTION_ADDRESS_INVALID();
}
else
{
/* Every byte of re-connection address is stored as a word in the
* firmware buffer. So, first create a variable of type BD_ADDR_T
* and copy the data from the firmware buffer to this variable.
*/
BD_ADDR_T temp_reconnect_address;
temp_reconnect_address.lap = p_val[0] | p_val[1] << 8 |
(uint24)p_val[2] << 16;
temp_reconnect_address.uap = p_val[3];
temp_reconnect_address.nap = p_val[4] | p_val[5] << 8;
MemCopy(&g_gap_data.reconnect_address, &temp_reconnect_address,
sizeof(BD_ADDR_T));
}
/* Write re-connection address to NVM */
Nvm_Write((uint16*)&g_gap_data.reconnect_address,
sizeof(BD_ADDR_T),
g_gap_data.nvm_offset +
GAP_NVM_DEVICE_RECONNECTION_ADDRESS_OFFSET);
/* The updated reconnection address needs to be in whitelist as the remote
* host may connect using this address during re-connection.
*/
AppUpdateWhiteList();
}
示例15: PrintStackSortNextItem
/*****************************************************************************
*
* PrintStackSortNextItem(dest, src, index, indent, next)
* Copies src[index] item to next available slot in dest
* Also copies sorted list of any subcomponents
* returns index to next item (based on sort_key) at this indent level
* returns -1 when no more items
*
*****************************************************************************/
static void PrintStackSortNextItem (PrintStackPtr dest, PrintStackPtr src,
Int2 index, Int2 indent)
{
Int2 tmp, max_key, min_key;
PrintStackItemPtr from, to;
if ((dest == NULL) || (src == NULL)) return;
to = PrintStackItemNew(dest); /* copy the one */
from = src->data + index;
MemCopy(to, from, sizeof(PrintStackItem));
min_key = from->pfip->sort_key;
max_key = PrintFormatListGetMaxKey(src->pflp, min_key);
/* any components to copy? */
tmp = PrintStackGetLowest(src, (Int2)(index + 1), (Int2)(indent + 1), index, max_key, min_key);
while (tmp >= 0) /* copy/sort any components */
{
PrintStackSortNextItem(dest, src, tmp, (Int2)(indent + 1));
tmp = PrintStackGetLowest(src, (Int2)(index + 1), (Int2)(indent+1), tmp, max_key, min_key);
}
return;
}