当前位置: 首页>>代码示例>>C++>>正文


C++ MemMove函数代码示例

本文整理汇总了C++中MemMove函数的典型用法代码示例。如果您正苦于以下问题:C++ MemMove函数的具体用法?C++ MemMove怎么用?C++ MemMove使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了MemMove函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SubstituteStr

/***********************************************************************
 *
 * FUNCTION:    SubstituteStr
 *
 * DESCRIPTION: This routine substitutes the occurrence a token, within
 *              a string, with another string.
 *
 * PARAMETERS:  str    - string containing token string
 *              token  - the string to be replaced
 *              sub    - the string to substitute for the token
 *              subLen - length of the substitute string.
 *
 * RETURNED:    pointer to the string
 *
 ***********************************************************************/
static Char* SubstituteStr(Char* str, const Char* token, const Char* sub, UInt16 subLen) {
  const UInt16 tokenLen = StrLen(token);
  const UInt16 charsToMove = subLen - tokenLen;
  const UInt16 strLen = StrLen(str);
  MemHandle strH = MemPtrRecoverHandle(str);
  const UInt16 blockSize = MemHandleSize(strH);
  Char* ptr = StrStr(str, token);

  ASSERT(str);
  ASSERT(token);
  ASSERT(sub);

  /* Find the start of the token string, if it doesn't exist, exit. */
  if (ptr == NULL)
    return str;

  /* Resize the string if necessary. */
  if (strLen + charsToMove + 1 >= blockSize) {
    MemHandleUnlock(strH);
    MemHandleResize(strH, strLen + charsToMove + 1);
    str = MemHandleLock(strH);
    ASSERT(str);
    ptr = StrStr(str, token);
    ASSERT(ptr);
  }

  /* Make room for the substitute string. */
  if (charsToMove)
    MemMove(ptr + subLen, ptr + tokenLen, StrLen (ptr + tokenLen)+1);
  
  /* Replace the token with the substitute string. */
  MemMove(ptr, sub, subLen);
  
  return str;
}
开发者ID:jemyzhang,项目名称:DiddleBug,代码行数:50,代码来源:repeat.c

示例2: TwGfxLockSurface

void OSystem_PalmZodiac::undraw_mouse() {
	if (!_mouseDrawn)
		return;

	int h = _mouseOldState.h;

	// no need to do clipping here, since draw_mouse() did that already
	if (_overlayVisible) {
		uint16 *dst;
		uint16 *bak = (uint16 *)_mouseBackupP;

		TwGfxLockSurface(_overlayP, (void **)&dst);
		dst += _mouseOldState.y * _screenWidth + _mouseOldState.x;

		do {
			MemMove(dst, bak, _mouseOldState.w * 2);
			dst += _screenWidth;
			bak += _mouseOldState.w;
		} while (--h);

		TwGfxUnlockSurface(_overlayP, true);

	} else {
		byte *dst = _offScreenP + _mouseOldState.y * _screenWidth + _mouseOldState.x;
		byte *bak = _mouseBackupP;

		do {
			MemMove(dst, bak, _mouseOldState.w);
			dst += _screenWidth;
			bak +=  _mouseOldState.w;
		} while (--h);
	}

	_mouseDrawn = false;
}
开发者ID:havlenapetr,项目名称:Scummvm,代码行数:35,代码来源:zodiac_mouse.cpp

示例3: stripCryptC

/*******************************************************
 * Function: stripCrypt
 * Description: encrypts/decrypts a memory block. puts 
 * the results into an out buffer. dkey is the string
 * ****************************************************/
void stripCryptC(char * ikey, MemPtr str, MemPtr out, int sLen, int enc)
{
       int offset=0;
	   char ivector[BLOCKC], ovector[BLOCKC], k[16]; 
		Boolean e;

		(enc==1)?(e=true):(e=false);
            //generate the key.
       MDString(ikey, k);
		xOrFold(k);

            //encrypt or decrypt block by block
       for(;offset<sLen;)
       {
           MemMove(ivector, str+offset, BLOCKC);
			EncDES(ivector, k, ovector, e);
           MemMove(out+offset, ovector, BLOCKC);
           offset+=BLOCKC;
       }  
       
            // wipeout keying info.
       MemSet(ivector, sizeof(ivector), 0);
       MemSet(ovector, sizeof(ovector), 0);
       MemSet(k,sizeof(k), 0);
}
开发者ID:sjlombardo,项目名称:strip-palm,代码行数:30,代码来源:desPalmDriverCS.c

示例4: stripCryptA

/*******************************************************
 * Function: stripCrypt
 * Description: encrypts/decrypts a memory block. puts 
 * the results into an out buffer. ikey is the string
 * ****************************************************/
void stripCryptA(char * ikey, MemPtr str, MemPtr out, int sLen, int enc)
{
       word32 vector[3], key[3];
       int offset=0;

            //generate the key.
       twKey(ikey, key);
       
            //encrypt or decrypt block by block
       for(;offset<sLen;)
       {
           MemMove(vector, str+offset, BLOCKA);
           if(enc)
               encrypt(vector, key);
           else
               decrypt(vector, key);
               
           MemMove(out+offset, vector, BLOCKA);
           offset+=BLOCKA;
       }  
       
            // wipe out keying info.
       MemSet(vector, 0, sizeof(vector));
       MemSet(key, 0, sizeof(key));   
}
开发者ID:sjlombardo,项目名称:strip-palm,代码行数:30,代码来源:twDriverCS.c

示例5: stripCrypt

/*******************************************************
 * Function: stripCrypt
 * Description: encrypts/decrypts a memory block. puts 
 * the results into an out buffer. ikey is the string
 * ****************************************************/
void stripCrypt(md5_hash * ikey, MemPtr str, MemPtr out, int sLen, int enc)
{
       Idea_Data ivector, ovector;
       Idea_UserKey k;
       Idea_Key ekey;
       int offset=0;

            //generate the key.
       MemMove(k, ikey, sizeof(md5_hash));

       Idea_ExpandUserKey(k, ekey);
       
       if(!enc)
            Idea_InvertKey(ekey, ekey);

            //encrypt or decrypt block by block
       for(;offset<sLen;)
       {
           MemMove(ivector, str+offset, BLOCK);
           Idea_Crypt(ivector, ovector, ekey);
           MemMove(out+offset, ovector, BLOCK);
           offset+=BLOCK;
       }  
       
            // wipeout keying info.
       MemSet(ivector, sizeof(ivector), 0);
       MemSet(ovector, sizeof(ovector), 0);
       MemSet(k,sizeof(k), 0);
       MemSet(ekey,sizeof(ekey), 0);   
}
开发者ID:sjlombardo,项目名称:strip-palm,代码行数:35,代码来源:idea_driver.c

示例6: twKey

/********************************************************
 * Function: twKey
 * Description: pass this function a null terminated
 * string or char array and it will generate a valid 
 * 96 bit key for the 3-way encryption algorithm. 
 * Method: generate the digest of the passed in string
 * followed by the digest for that digest. concatonate
 * the two arrays and get one big array of 256 bits.
 * Ignore the last 64 bits. take the resulting 192 bits 
 * and fold the last 96 bits over the first 96 bits using
 * and XOR. i.e bit[n]^=bit[n+96]. the resulting array is
 * 96 bits its bit pattern is totaly dependent on the 
 * original strings message digest. If anyone cant think
 * of a better way to do this, let me know.
 * ******************************************************/
void twKey(char * ikey, MemPtr out)
{
       int i;
       char dKey[24], mdKey1[16], mdKey2[16];
      
       // Hash the input string, hash the output, then concatonate 
       MDString(ikey, mdKey1);
       MDBlock(mdKey1, 16, mdKey2);

       //concatanate the arrays
       MemMove(dKey, mdKey1, 16);
       MemMove(dKey+16, mdKey2, 8);

       //now fold dKey over itself at 96 bits, XORing as we go.
       for(i=0; i<12; i++)
       {
           dKey[i]^=dKey[i+BLOCKA];
       }

       MemMove(out, dKey, BLOCKA);
       
            //wipe out keying info.
       MemSet(dKey,0, sizeof(dKey));
       MemSet(mdKey1, 0, sizeof(mdKey1));
       MemSet(mdKey2, 0, sizeof(mdKey2));
}
开发者ID:sjlombardo,项目名称:strip-palm,代码行数:41,代码来源:twDriverCS.c

示例7: sortScript

void sortScript()
{
	//this saves dynamic space
	UInt16 i, k, size;
	Err err;
	ScriptType temp[map.numCmds];
	
	//get rid of all map cmds
	for(i = 0; i < map.numCmds; i++)
	{
		if(!cmdIsAI(script[i].type))
		{
			//copy next cmd into this one if there is			
			for(k = i; k < map.numCmds;k++)
			{
				//if there is a cmd left
				if(k != (map.numCmds - 1))
				{
					//if it still isn't ai then continue
					if(!cmdIsAI(script[k + 1].type))
					{
						continue;
					}
					else
					{
						//copy it into new, discard old
						MemMove(&temp[i], &script[k + 1], sizeof(ScriptType));						
						size++;
						//get out of loop
						break;
					}	
				}
			}
		}	
		//leave it if it is an ai	
	}	
	
	//resize script to value of size
	err = MemHandleResize(scriptH, sizeof(ScriptType) * size);
	if(err == memErrChunkLocked)
	{
		//unlock
		MemHandleUnlock(scriptH);
		if(err = MemHandleResize(scriptH, sizeof(ScriptType) * size))
		{
			ErrFatalDisplay("In sortscript, couldn't resize script");
		}
		script = (ScriptType *)MemHandleLock(scriptH);		 
	}		
	else if(err != 0)
	{
		//some other error
		ErrFatalDisplay("In sortscript, couldn't resize script");	
	}	
	
	//move all script into new one
	MemMove(script, &temp, sizeof(ScriptType) * size);
}
开发者ID:geoffmacd,项目名称:Allied-Ace,代码行数:58,代码来源:ai.c

示例8: LoadRecordData

/*
** Load the record data (flags, ...) - but not the picture
*/
static void LoadRecordData(void) {
  MemHandle t = NULL;
  MemPtr ptr = NULL;
  UInt16 attr = 0;
  UInt32 highDataOffset = 0;
  Int16 len = 0;

  PRINT("Loading Record Data for %hd", p.dbI);

  /* Clear unmasked flag */
  d.unmaskedCurrentRecord = false;

  /* Open and lock the record */
  t = DmQueryRecord(d.dbR, p.dbI);
  if (!t) abort();
  ptr = MemHandleLock(t);

  /* Is the record private? */
  DmRecordInfo(d.dbR, p.dbI, &attr, NULL, NULL);
  d.record_private = attr & dmRecAttrSecret;

  /* Read the header data */
  MemMove(&d.record, ptr, sizeof(DiddleBugRecordType));

  /* Read the additional alarm info */
  highDataOffset = sketchDataOffset + d.record.sketchLength;

  len = StrLen((Char*)(ptr + highDataOffset)) + 1; /* +1 for null char */
  if (d.record_name) MemHandleFree(d.record_name);
  d.record_name = MemHandleNew(len);
  ASSERT(d.record_name);
  MemMove(MemHandleLock(d.record_name), ptr + highDataOffset, len);
  MemHandleUnlock(d.record_name);

  highDataOffset += len;

  len = StrLen((Char*)(ptr + highDataOffset)) + 1; /* +1 for null char */
  if (d.record_note) MemHandleFree(d.record_note);
  d.record_note = MemHandleNew(len);
  ASSERT(d.record_note);
  MemMove(MemHandleLock(d.record_note), ptr + highDataOffset, len);
  MemHandleUnlock(d.record_note);

  highDataOffset += len;

  /* Clear old data since there may not be an extra-data block yet */
  MemSet(&d.record_sound, sizeof(AlarmSoundInfoType), 0);
  d.record_sound.listIndex = -1; /* default */
  /* Read new extra-data (if it exists and is from a compatible version) */
  if (d.record.extraLength == sizeof(AlarmSoundInfoType))
    MemMove(&d.record_sound, ptr + highDataOffset, d.record.extraLength);

  /* Unlock record */
  MemHandleUnlock(t);
}
开发者ID:jemyzhang,项目名称:DiddleBug,代码行数:58,代码来源:thumbnails_details.c

示例9: generateAccountHash

/**************************************************************************
 * Function: generateAccountHash
 * Description: returns the unique hash for the account.
 * ************************************************************************/ 
md_hash * generateAccountHash (Account * acct) {
	static md_hash ret;
	unsigned char * hashable;
	int data_length = 0, string_length = 0;
	
	MemSet(ret, sizeof(md_hash), 0);
	
	/* username, password, acct mod date, 
	 * pw mod date, and 256 bits of randomness */
	data_length = 
		StrLen(acct->username)+
		StrLen(acct->system)+
		StrLen(acct->password)+
		StrLen(acct->service)+
		StrLen(acct->comment)+
		sizeof(acct->account_mod_date)+
		sizeof(acct->password_mod_date)+
		(sizeof(Int16)*16)+1;
		
		
	if((hashable=MemPtrNew(data_length))) {
		MemSet(hashable, data_length, 0);
		StrCopy(hashable, acct->username);	
		string_length+=StrLen(acct->username);
		StrCat(hashable, acct->system);	
		string_length+=StrLen(acct->system);
		StrCat(hashable, acct->password);
		string_length+=StrLen(acct->password);	
		StrCat(hashable, acct->service);
		string_length+=StrLen(acct->service);	
		StrCat(hashable, acct->comment);
		string_length+=StrLen(acct->comment);	
		
		MemMove(hashable+string_length, 
			&acct->account_mod_date, 
			sizeof(acct->account_mod_date));
		string_length+=sizeof(acct->account_mod_date);
		
		MemMove(hashable+string_length, 
			&acct->password_mod_date, 				
			sizeof(acct->password_mod_date));
		string_length+=sizeof(acct->password_mod_date);
		
		/* move some randomness onto the end 
		 * to make dictionary attacks impossible.   */
		random_bytes(hashable+string_length, 32);
		string_length+=32;
		
		md_block(hashable, string_length, ret);	
		MemPtrFree(hashable);
	}	
	return &ret;
}
开发者ID:sjlombardo,项目名称:strip-palm,代码行数:57,代码来源:account_hash.c

示例10: switch

/* Handle the Gesture preferences */
Boolean PrefsGesturePreferenceEvent
    (
    ActionType action
    )
{
    Boolean handled;

    handled = false;

    switch ( action ) {
        case AVAILABLE:
            /* Always available */
            handled = true;
            break;

        case SHOWFIRST:
            handled = showFirst;
            showFirst = false;
            break;

        case LOAD:
            gestureSelected = GESTURES_UP;
            MemMove( gestureMode, Prefs()->gestMode, sizeof( gestureMode ) );
            InitializeActionList( frmPrefsGestureActionList );
            CtlSetValue( GetObjectPtr( frmPrefsGestureGestures ),
                Prefs()->gestures );
            SetListToSelection( frmPrefsGestureActionList,
                frmPrefsGestureSelectAction, gestureMode[ gestureSelected ] );
            handled = true;
            break;

        case DISPLAY:
            AffirmControlImage( gestureSelected, frmPrefsGestureUp,
                bmpGestureUp );
            handled = true;
            break;

        case SAVE:
            Prefs()->gestures = CtlGetValue( GetObjectPtr(
                frmPrefsGestureGestures ) );
            MemMove( Prefs()->gestMode, gestureMode, sizeof( gestureMode ) );
            handled = true;
            break;

        default:
            handled = false;
            break;
    }
    return handled;
}
开发者ID:TimofonicJunkRoom,项目名称:plucker,代码行数:51,代码来源:prefsgesture.c

示例11: UnpackAccount_old

/************************************************************************************
 * Function: UnpackAccountA
 * Description: This is a utility function that will take a packed account ,
 * optionally decrypt it based on the passed in password, and set up 
 * an unpacked account. isRec determines whether the packed account is a full record.
 * remember that fullrecords have the plaintext system id prepended, so if it
 * is a full record we will ignore this space.
 * **********************************************************************************/ 
static void 
UnpackAccount_old (Account_old * acct, MemPtr p, MemPtr scratch,
				char *pass, UInt16 recLen, Boolean decrypt, Boolean isRec,
				int v) 
{
	PAccount_old * pacct;
	char *s;

	UInt16 offset = sizeof (offset);
	recLen = recLen - offset;
	
		// decrypt if neccessary
	if (decrypt)
		switch (v)
			
		{
			case 0:
				stripCrypt_tw (pass, p + offset, scratch, recLen, 0);
				break;
			case 1:
				stripCrypt_idea (pass, p + offset, scratch, recLen, 0);
				break;
			case 2:
				stripCrypt_des (pass, p + offset, scratch, recLen, 0);
				break;
		}	
	else
		
			// if buffer has the systemID header disregard it.
		if (isRec)
		MemMove (scratch, p + offset, recLen);
	
	else
		MemMove (scratch, p, recLen);
	
		// split record up into its different components.   
		pacct = (PAccount_old *) scratch;
	s = pacct->username;
	acct->SystemID = pacct->SystemID;
	acct->AccountID = pacct->AccountID;
	acct->username = s;
	s += StrLen (s) + 1;
	acct->password = s;
	s += StrLen (s) + 1;
	acct->type = s;
	s += StrLen (s) + 1;
	acct->comment = s;
	s += StrLen (s) + 1;
}
开发者ID:sjlombardo,项目名称:strip-palm,代码行数:57,代码来源:StripCS.c

示例12: PrvAddPadding

static Char * PrvAddPadding(Char * startOfBlock, Char * dstP, const Int16 minimumSize,
	const Boolean leftJustify, Boolean zeroPad, Char sign)
{	
	Int16 stringSize = StrLen(startOfBlock);
	
	ErrNonFatalDisplayIf( sign && (sign != '+') && (sign != ' '), "illegal sign character specified in PrvAddPadding" );
	
	if (leftJustify && stringSize < minimumSize)		// Left Justified
		{
		MemSet(dstP, minimumSize - stringSize, ' ');
		dstP += minimumSize - stringSize;
		*dstP = '\0';
		}
	else if (!leftJustify && stringSize < minimumSize)	// Right Justified
		{
		
		// If there is a sign present and the calling function as specified padding with
		// zero bytes then do not move the sign character with the rest of the value.
		if ( (sign == '+' || sign == ' ') && zeroPad )
			{
			// If there is a sign present then only MemMove the value and not the sign.
			// The value will be moved minimum size specified for this value minus the
			// actual string size of the value plus the size of the sign (1).
			MemMove(startOfBlock + minimumSize - stringSize + 1, startOfBlock + 1, 
						stringSize - 1);
						
			// MemSet the space between the sign and moved value with the desired
			// padding value.
			MemSet(startOfBlock + 1, minimumSize - stringSize, zeroPad ? '0' : ' ');
			}
		else
			{
			// MemMove the value and any potential sign character to make room for padding
			// characters.  The number of bytes to move is determined by the minimum string
			// specified for the value minus the actual string size of the value.
			MemMove(startOfBlock + minimumSize - stringSize, startOfBlock, stringSize);
			
			// MemSet the space between the sign and moved value with the desired
			// padding value.
			MemSet(startOfBlock, minimumSize - stringSize, zeroPad ? '0' : ' ');
			}	
			
		dstP += minimumSize - stringSize;
		*dstP = '\0';
		}
		
	return dstP;
}
开发者ID:kernelhcy,项目名称:hcyprojects,代码行数:48,代码来源:StringMgr.c

示例13: deserData

void deserData(unsigned char *valOut, int len, const unsigned char **data, long *pBlobSizeLeft)
{
    Assert( data && *data && pBlobSizeLeft && (*pBlobSizeLeft>=len) );
    MemMove( valOut, *data, len );
    *data = *data+len;
    *pBlobSizeLeft -= len;
}
开发者ID:kjk,项目名称:ars-framework,代码行数:7,代码来源:PrefsStore.cpp

示例14: UnpackSystem_old

/************************************************************************************
 * Function: UnpackSystem_old
 * Description: This is a utility function that will take a packed System ,
 * optionally decrypt it based on the passed in password, and set up 
 * an unpacked system. 
 * **********************************************************************************/ 
static void 
UnpackSystem_old (System_old * sys, MemPtr p, MemPtr scratch, char *pass,
			   UInt16 recLen, Boolean decrypt, int v) 
{
	PSystem_old * psys;
	char *s;

	
		// if necessary, decrypt, otherwise just copy the memory to the scratch buffer
		if (decrypt)
		switch (v)
			
		{
			case 0:
				stripCrypt_tw (SysPass, p, scratch, recLen, 0);
				break;
			case 1:
				stripCrypt_idea (SysPass, p, scratch, recLen, 0);
				break;
			case 2:
				stripCrypt_des (SysPass, p, scratch, recLen, 0);
				break;
		}
	
	else
		MemMove (p, scratch, recLen);
	
		// set up the system, pointing the name to the first char in the name string.
		psys = (PSystem_old *) scratch;
	s = psys->name;
	sys->SystemID = psys->SystemID;
	sys->name = s;
	s += StrLen (s) + 1;
}
开发者ID:sjlombardo,项目名称:strip-palm,代码行数:40,代码来源:StripCS.c

示例15: PrvRealloc

void* PrvRealloc(void* p, UInt32 newSize)
{
    if (0 == newSize)
    {
        if (NULL != p)
            MemPtrFree(p);
        return NULL;
    }
    newSize = PrvBlockSize(newSize);
    if (NULL == p)
        return MemGluePtrNew(newSize);

    UInt32 size = MemPtrSize(p);
    if (newSize <= size)
        return p;

    Err err = MemPtrResize(p, newSize);
    if (errNone == err)
        return p;

    void* np = MemGluePtrNew(newSize);
    if (NULL != np)
        MemMove(np, p, size);

    MemPtrFree(p);
    return np;
}
开发者ID:kjk,项目名称:moriarty-palm,代码行数:27,代码来源:FlickrImpl.cpp


注:本文中的MemMove函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。