• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ MemCpy函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Read

   virtual bool Read(void *mem, dword len){

      dword read_len = 0;
      const dword wanted_len = len;
      dword rl = 0;
      while(curr+len>top){
         dword rl1 = top-curr;
         MemCpy(mem, curr, rl1);
         len -= rl1;
         mem = (byte*)mem + rl1;
         dword sz = ReadCache();
         top = base + sz;
         curr_pos += sz;
         rl += rl1;
         if(!sz){
            read_len = rl;
            goto check_read_size;
            //return rl;
         }
      }
      MemCpy(mem, curr, len);
      curr += len;
      read_len = rl + len;
      //return rl + len;
check_read_size:
      return (read_len == wanted_len);
   }
开发者ID:turbanoff,项目名称:X-plore,代码行数:27,代码来源:C_file.cpp


示例2: String_Concat

/// <summary>
/// Construct a new String instance by concatenating exactly two strings together.
/// </summary>
/// <param name="str">The first string to concatenate.</param>
/// <param name="other">The second string to concatenate.</param>
/// <returns>The new String instance.</returns>
String String_Concat(const String str, const String other)
{
	struct StringInt *result, *s1, *s2;
	Byte *newText;
	Int length;

	s1 = (struct StringInt *)str;
	s2 = (struct StringInt *)other;

	if (s1 == NULL || s1->length == 0) return s2 != NULL ? (String)s2 : String_Empty;
	if (s2 == NULL || s2->length == 0) return (String)s1;

	length = s1->length + s2->length;

	result = GC_MALLOC_STRUCT(struct StringInt);
	if (result == NULL) Smile_Abort_OutOfMemory();
	newText = GC_MALLOC_TEXT(length);
	if (newText == NULL) Smile_Abort_OutOfMemory();

	result->length = length;
	result->text = newText;

	MemCpy(newText, s1->text, s1->length);
	MemCpy(newText + s1->length, s2->text, s2->length);
	newText[length] = '\0';

	return (String)result;
}
开发者ID:orbitalbits,项目名称:smile,代码行数:34,代码来源:string_core.c


示例3: MemCpy

//
// TextPacket::TextPacket			- not described in the book
//
TextPacket::TextPacket(char const * const text)
 :BinaryPacket(static_cast<u_long>(strlen(text) + 2))
{ 
	MemCpy(text, strlen(text), 0);
	MemCpy("\r\n", 2, 2);
	*(u_long *)m_Data = 0;
}
开发者ID:KevinMackenzie,项目名称:AmberRabbit,代码行数:10,代码来源:Network.cpp


示例4: LoadFile

Map *ReadMap(char *name)
{
    char *buf;
    int x, y, i, n;
    Map *map = NULL;
    char *data;

    buf = LoadFile(name, &n);
    data = buf;
    map = (Map *)Malloc(sizeof(Map));
    map->object = NULL;
    MemCpy(&map->width, buf, sizeof(int));
    buf += sizeof(int);
    MemCpy(&map->height, buf, sizeof(int));
    buf += sizeof(int);
    map->data = (struct MapData *)Malloc(sizeof(struct MapData) * map->width * map->height);
    for (y = 0; y < map->height; y++) {
        for (x = 0; x < map->width; x++) {
            MemCpy(&map->data[POS(x, y)], buf, sizeof(struct MapData));
            buf += sizeof(struct MapData);
        }
    }
    MemCpy(&map->objectNum, buf, sizeof(int));
    buf += sizeof(int);
    map->object = (struct ObjectData *)Malloc(sizeof(struct ObjectData) * map->objectNum);    
    for (i = 0; i < map->objectNum; i++) {
        MemCpy(&map->object[i], buf, sizeof(struct ObjectData));
        buf += sizeof(struct ObjectData);
    }
    Free(data);
    return map;
}
开发者ID:f3yagi,项目名称:mysrc,代码行数:32,代码来源:map.cpp


示例5: Codec618CmdWrite

static int Codec618CmdWrite(RK618_DEVICE_CLASS *dev,UINT16 RegAddr, UINT32 uData)
{
    uint8 cmd,data[4];
    I2C_CMD_ARG stArg;
    uint32 set_bit, read_value, new_value;
    int i;

    HDC hI2c = dev->hI2C;
    if(hI2c != NULL)
    {
        if (!Is_rk618_mfd_register(RegAddr) && !Is_rk618_codec_register(RegAddr))
        {
    		rk_printf("%s : reg error!\n", __func__);
    		return -EINVAL;
    	}

    	// set codec mask bit
    	i = rk618_mfd_codec_bit(RegAddr);
    	if (i >= 0)
        {
    		set_bit = rk618_mfd_codec_bit_list[i].value;
    		read_value = Codec618CmdRead(dev, RegAddr);
    		uData = (read_value & ~set_bit) | (uData & set_bit);
    	}
        else if (Is_rk618_mfd_mask_register(RegAddr))
        {
    		uData = ((0xffff0000 & rk618_read_reg_cache(RegAddr)) | (uData & 0x0000ffff));
    	}

        new_value = rk618_set_init_value(dev, RegAddr, uData);

//        data[0] = (0xff & uData);
//        data[1] = (0xff00 & uData) >> 8;
//        data[2] = (0xff0000 & uData)>>16;
//        data[3] = (0xff000000 & uData)>>24;
        MemCpy(data, (uint8 *)&uData, 4);

        stArg.SlaveAddress  = RK618_Codec_I2CAddr;
        stArg.RegAddr       = RegAddr;
        stArg.RWmode        = NormalMode;
        stArg.speed         = RK618_Codec_I2CSpeed;
        stArg.addr_reg_fmt  = I2C_7BIT_ADDRESS_16BIT_REG;

        I2cDev_SendData(hI2c,data,4,&stArg);

	    if (new_value != uData)
        {
            MemCpy(data, (uint8 *)&new_value, 4);
            I2cDev_SendData(hI2c,data,4,&stArg);
		    uData = new_value;
	    }

	    rk618_write_reg_cache(RegAddr, uData);
    }

    return 0;
}
开发者ID:wjw890912,项目名称:RK_NanoD_WIFI_demo,代码行数:57,代码来源:RK618Device.c


示例6: SgOpsCpy

void SgOpsCpy(T_SgOps *t, const T_SgOps *s)
{
  t->NoExpand = s->NoExpand;
  t->nLSL = s->nLSL;
  t->nSSL = s->nSSL;
  t->nLTr = s->nLTr;
  t->fInv = s->fInv;
  t->nSMx = s->nSMx;
  MemCpy(t->LTr, s->LTr, SgOps_mLTr);
  MemCpy(t->InvT, s->InvT, 3);
  MemCpy(t->SMx, s->SMx, SgOps_mSMx);
}
开发者ID:rwgk,项目名称:sglite,代码行数:12,代码来源:sgutil.c


示例7: FatWriteBootRecord

int FatWriteBootRecord (struct FatSB *fsb)
{
	uint8 temp_sector[512];
	uint16 signature;
	int t;
	
	KPRINTF ("FatWriteBootRecord()");
	
	ReadBlocks (fsb, &kernel_as, temp_sector, 0, 0, 512);

	MemCpy (temp_sector, &fsb->bpb, sizeof (struct FatBPB));
	
	
	if (fsb->fat_type == TYPE_FAT32)
	{
		MemCpy (temp_sector + BPB_EXT_OFFSET, &fsb->bpb32, sizeof (struct FatBPB_32Ext));
		MemCpy (temp_sector + FAT32_BOOTCODE_START, fat32_bootcode, SIZEOF_FAT32_BOOTCODE);
	}
	else
	{
		MemCpy (temp_sector + BPB_EXT_OFFSET, &fsb->bpb16, sizeof (struct FatBPB_16Ext));
		MemCpy (temp_sector + FAT16_BOOTCODE_START, fat16_bootcode, SIZEOF_FAT16_BOOTCODE);
	}
	
	*(temp_sector + 510) = 0x55;
	*(temp_sector + 511) = 0xaa;	

	WriteBlocks (fsb, &kernel_as, temp_sector, 0, 0, 512, BUF_IMMED);
	
	
	
	
	
	
	if (fsb->fat_type == TYPE_FAT32)
	{		
		WriteBlocks (fsb, &kernel_as, &fsb->fsi, 1, 0, sizeof (struct FatFSInfo), BUF_IMMED);
			
		signature = 0xaa55;
				
		WriteBlocks (fsb, &kernel_as, &signature, 2, 510, 2, BUF_IMMED);
		
		
		for (t=0; t<3; t++)
		{			
			ReadBlocks (fsb, &kernel_as, temp_sector, t, 0, 512);
			WriteBlocks (fsb, &kernel_as, temp_sector, 6+t, 0, 512, BUF_IMMED);
		}
	}
	
	return 0;
}
开发者ID:cod5,项目名称:kielder,代码行数:52,代码来源:format.c


示例8: HTSwitchDTD

/* This function fills the "tags" part of the HTML_dtd structure with
   what we want to use, either tags_table0 or tags_table1.  Note that it
   has to be called at least once before HTML_dtd is used, otherwise
   the HTML_dtd contents will be invalid!  This could be coded in a way
   that would make an initialisation call unnecessary, but my C knowledge
   is limited and I didn't want to list the whole tags_table1 table
   twice... - kw */
void HTSwitchDTD(int new_flag)
{
    if (TRACE)
	CTRACE((tfp,
		"HTMLDTD: Copying %s DTD element info of size %d, %d * %d\n",
		new_flag ? "strict" : "tagsoup",
		(int) (new_flag ? sizeof(tags_table1) : sizeof(tags_table0)),
		HTML_ALL_ELEMENTS,
		(int) sizeof(HTTag)));
    if (new_flag)
	MemCpy(tags, tags_table1, HTML_ALL_ELEMENTS * sizeof(HTTag));
    else
	MemCpy(tags, tags_table0, HTML_ALL_ELEMENTS * sizeof(HTTag));
}
开发者ID:AaronDP,项目名称:lynx_adbshell,代码行数:21,代码来源:HTMLDTD.c


示例9: AddOneDevice

//增加一条记录,并同步显示
//Addr不能为0,Name可以为空,name为空,则不修改name
static void AddOneDevice(u8 Addr,u8 *Name)
{
	u8 i;
	u8 Len=0;
	u16 NameChk;

	if(Name!=NULL) Len=strlen((void *)Name);
	if(Len>=DEVICE_NAME_MAX_LEN) Len=DEVICE_NAME_MAX_LEN-1;
	NameChk=MakeHash33(Name,Len);

	for(i=0;i<DEVICE_INFO_MAX_CLIENT_RECORD;i++)
	{
		//对比地址或名字,如果地址相等,直接修改名字,如果名字相同,则修改地址。
		if((gpQwpVar->ClientRecord[i].Addr==Addr)||((gpQwpVar->ClientRecord[i].Addr!=0)&&(gpQwpVar->ClientRecord[i].NameChk==NameChk)))
		{//修改现成的
			gpQwpVar->ClientRecord[i].Addr=Addr;
			
			if((Name!=NULL)&&(gpQwpVar->ClientRecord[i].NameChk!=NameChk))//修改名字
			{
				MemCpy(gpQwpVar->ClientRecord[i].Name,Name,Len);
				gpQwpVar->ClientRecord[i].Name[Len]=0;
			}

			if(gpQwpVar->ClientRecord[i].IsHiLight==TRUE)
				DrawDeviceInfo(gpQwpVar->ClientRecord[i].DispIdx,Addr,gpQwpVar->ClientRecord[i].Name,HighLightDisp);
			else
				DrawDeviceInfo(gpQwpVar->ClientRecord[i].DispIdx,Addr,gpQwpVar->ClientRecord[i].Name,NormalDisp);
			break;
		}
	}

	if(i==DEVICE_INFO_MAX_CLIENT_RECORD)//not found ,add new one.
	{//建新的
		for(i=0;i<DEVICE_INFO_MAX_CLIENT_RECORD;i++)
			if(gpQwpVar->ClientRecord[i].Addr==0)
			{
				gpQwpVar->ClientRecord[i].Addr=Addr;
				MemCpy(gpQwpVar->ClientRecord[i].Name,Name,Len);
				gpQwpVar->ClientRecord[i].Name[Len]=0;
				gpQwpVar->ClientRecord[i].NameChk=MakeHash33(gpQwpVar->ClientRecord[i].Name,Len);
				gpQwpVar->ClientRecord[i].DispIdx=++gpQwpVar->NowDispNum;
				DrawDeviceInfo(gpQwpVar->ClientRecord[i].DispIdx,Addr,gpQwpVar->ClientRecord[i].Name,NormalDisp);
				break;
			}
	}	

	DrawState();//更新下状态
}
开发者ID:beartan,项目名称:q-sys,代码行数:50,代码来源:QWebPage.c


示例10: GetVGAPalette4

public CTaskSettings *SettingsPush(CTask *task=NULL,I64 flags=0)
{ //This is typically used at the start of an application.
  //It saves many settings so they can be restored
  //at the end of the application with $LK,"SettingsPop","MN:SettingsPop"$().

  CTaskSettings *tempse;
  CDoc *doc;
  if (!task) task=Fs;
  if (!TaskValidate(task)) return NULL;
  tempse=CAlloc(sizeof(CTaskSettings),task);
  tempse->draw_it=task->draw_it;
  GetVGAPalette4(tempse->palette4);
  tempse->task_end_cb=task->task_end_cb;

  if (!(flags&TSF_SAME_SONG)) {
    if (tempse->song_task=task->song_task) {
      Suspend(task->song_task);
      Snd(0);
    }
    task->song_task=NULL;
  }

  if (tempse->animate_task=task->animate_task)
    Suspend(task->animate_task);
  task->animate_task=NULL;

  if (doc=DocPut(task)) {
    tempse->cursor=!Bt(&doc->flags,DOCf_HIDE_CURSOR);
    tempse->scroll=!Bt(&doc->flags,DOCf_NO_SCROLL_BARS);
  }

  tempse->left=task->win_left;
  tempse->right=task->win_right;
  tempse->top=task->win_top;
  tempse->bottom=task->win_bottom;

  tempse->scroll_x=task->win_scroll_x;
  tempse->scroll_y=task->win_scroll_y;
  tempse->scroll_z=task->win_scroll_z;

  tempse->win_inhibit=task->win_inhibit;
  MemCpy(&tempse->snap,&task->snap,sizeof(CSnap));

  tempse->win_max_refresh=task->win_max_refresh;
  tempse->text_attr=task->text_attr;
  StrCpy(tempse->task_title,task->task_title);
  tempse->title_src  =task->title_src;
  tempse->border_attr=task->border_attr;
  tempse->border_src =task->border_src;
  tempse->border=!Bt(&task->display_flags,DISPLAYf_NO_BORDER);
  tempse->preempt=Bt(&task->task_flags,TASKf_PREEMPT);
  if (TaskValidate(ws_task))
    tempse->wordstat=TRUE;
  else
    tempse->wordstat=FALSE;

  tempse->next=task->next_settings;
  task->next_settings=tempse;
  return tempse;
}
开发者ID:IAmAnubhavSaini,项目名称:templeos,代码行数:60,代码来源:TaskSettings.CPP


示例11: SettingsPop2

U0 SettingsPop2(CTask *task,CTaskSettings *tempse)
{
  CDoc *doc;

  if (doc=DocPut(task)) {
    LBEqu(&doc->flags,DOCf_HIDE_CURSOR,!tempse->cursor);
    LBEqu(&doc->flags,DOCf_NO_SCROLL_BARS,!tempse->scroll);
  }

  WinBorder(tempse->border,task);
  SetWinHorz(tempse->left,tempse->right,task);
  SetWinVert(tempse->top,tempse->bottom,task);
  task->win_scroll_x=tempse->scroll_x;
  task->win_scroll_y=tempse->scroll_y;
  task->win_scroll_z=tempse->scroll_z;
  MemCpy(&task->snap,&tempse->snap,sizeof(CSnap));
  task->win_inhibit=tempse->win_inhibit;
  task->win_max_refresh=tempse->win_max_refresh;
  task->text_attr=tempse->text_attr;
  task->border_attr=tempse->border_attr;
  task->border_src =tempse->border_src;
  task->title_src  =tempse->title_src;
  StrCpy(task->task_title,tempse->task_title);
  WordStat(tempse->wordstat);
  SetVGAPalette4(tempse->palette4);
  Snd(0);
}
开发者ID:IAmAnubhavSaini,项目名称:templeos,代码行数:27,代码来源:TaskSettings.CPP


示例12: String_ConcatByte

/// <summary>
/// Construct a new String instance by concatenating a byte onto the end of a string.
/// </summary>
/// <param name="str">The string to concatenate.</param>
/// <param name="ch">The byte to append to it.</param>
/// <returns>The new String instance.</returns>
String String_ConcatByte(const String str, Byte ch)
{
	struct StringInt *result, *s1;
	Byte *newText;
	Int length;

	s1 = (struct StringInt *)str;

	if (s1 == NULL || s1->length == 0)
		return String_CreateRepeat(ch, 1);

	length = s1->length + 1;

	result = GC_MALLOC_STRUCT(struct StringInt);
	if (result == NULL) Smile_Abort_OutOfMemory();
	newText = GC_MALLOC_TEXT(length);
	if (newText == NULL) Smile_Abort_OutOfMemory();

	result->length = length;
	result->text = newText;

	MemCpy(newText, s1->text, s1->length);
	newText[length-1] = ch;
	newText[length] = '\0';

	return (String)result;
}
开发者ID:orbitalbits,项目名称:smile,代码行数:33,代码来源:string_core.c


示例13: MS_Inquire

/*********************************************************************//**
 * @brief 			Inquiry the mass storage device.
 * @param[in]		None.
 * @return 		MS_FUNC_OK       if Success
 *				ERR_MS_CMD_FAILED if failed
 **********************************************************************/
int32_t MS_Inquire (uint8_t *response)
{
    int32_t rc;
	uint32_t i;

    Fill_MSCommand(0, 0, 0, MS_DATA_DIR_IN, SCSI_CMD_INQUIRY, 6);
    rc = Host_ProcessTD(EDBulkOut, TD_OUT, TDBuffer, CBW_SIZE);
    if (rc == MS_FUNC_OK) {
        rc = Host_ProcessTD(EDBulkIn, TD_IN, TDBuffer, INQUIRY_LENGTH);
        if (rc == MS_FUNC_OK) {
            if (response) {
		for ( i = 0; i < INQUIRY_LENGTH; i++ )
			*response++ = *TDBuffer++;
#if 0
            	MemCpy (response, TDBuffer, INQUIRY_LENGTH);
	        	StrNullTrailingSpace (response->vendorID, SCSI_INQUIRY_VENDORCHARS);
	        	StrNullTrailingSpace (response->productID, SCSI_INQUIRY_PRODUCTCHARS);
	        	StrNullTrailingSpace (response->productRev, SCSI_INQUIRY_REVCHARS);
#endif
            }
            rc = Host_ProcessTD(EDBulkIn, TD_IN, TDBuffer, CSW_SIZE);
            if (rc == MS_FUNC_OK) {
                if (TDBuffer[12] != 0) {	// bCSWStatus byte
                    rc = ERR_MS_CMD_FAILED;
                }
            }
        }
    }
    return (rc);
}
开发者ID:tongjingyu,项目名称:nxp-os,代码行数:36,代码来源:usbhost_ms.c


示例14: hidGetInfoCmd

//----- (000025B8) --------------------------------------------------------
__myevic__ uint32_t hidGetInfoCmd( CMD_T *pCmd )
{
	uint32_t u32StartAddr;
	uint32_t u32ParamLen;

	u32StartAddr = pCmd->u32Arg1;
	u32ParamLen = pCmd->u32Arg2;

	myprintf( "Get Info command - Start Addr: %d    Param Len: %d\n", pCmd->u32Arg1, pCmd->u32Arg2 );

	if ( u32ParamLen )
	{
		dfChecksum = Checksum( (uint8_t *)DataFlash.params, FMC_FLASH_PAGE_SIZE - 4 );

		if ( u32StartAddr + u32ParamLen > FMC_FLASH_PAGE_SIZE )
		{
			u32ParamLen = FMC_FLASH_PAGE_SIZE - u32StartAddr;
		}

		MemCpy( hidData, ((uint8_t *)&DataFlash) + u32StartAddr, u32ParamLen );

		hidDataIndex = u32ParamLen;
		pCmd->u32Signature = u32ParamLen;

		USBD_MemCopy(
			(uint8_t *)(USBD_BUF_BASE + USBD_GET_EP_BUF_ADDR(EP2)),
			hidData,
			EP2_MAX_PKT_SIZE
		);
		USBD_SET_PAYLOAD_LEN( EP2, EP2_MAX_PKT_SIZE );
		hidDataIndex -= EP2_MAX_PKT_SIZE;
	}

	return 0;
}
开发者ID:shaman7036,项目名称:myevic,代码行数:36,代码来源:meusbd.c


示例15: readDirFiller

//Function called by filesystems to fill readdir entry
static int readDirFiller(void * buf, unsigned int iNode, const char * name, int len)
{
	//Called to fill buffer
	ReadDirFillerBuf * rdBuffer = (ReadDirFillerBuf *) buf;
	IoReadDirEntry * entry = rdBuffer->nextEntry;

	//If count is 0, overflow
	if(rdBuffer->count == 0)
	{
		return -EINVAL;
	}

	//Basic memory checks
	if(!MemCommitForWrite(entry, sizeof(IoReadDirEntry)))
	{
		return -EFAULT;
	}

	//Fill info
	entry->iNode = iNode;
	if(len > 255)
	{
		len = 255;
	}

	MemCpy(entry->name, name, len);
	entry->name[len] = '\0';

	//Move to next entry
	rdBuffer->nextEntry++;
	rdBuffer->count--;
	return 0;
}
开发者ID:jcowgill,项目名称:chaff,代码行数:34,代码来源:iocontext.c


示例16: hidGetInfoCmd

//----- (000025B8) --------------------------------------------------------
__myevic__ uint32_t hidGetInfoCmd( CMD_T *pCmd )
{
	uint32_t u32StartAddr;
	uint32_t u32ParamLen;

	u32StartAddr = pCmd->u32Arg1;
	u32ParamLen = pCmd->u32Arg2;

	myprintf( "Get Info command - Start Addr: %d    Param Len: %d\n", pCmd->u32Arg1, pCmd->u32Arg2 );

	if ( u32ParamLen )
	{
		dfChecksum = Checksum( (uint8_t *)DataFlash.params, FMC_FLASH_PAGE_SIZE - 4 );

		if ( u32StartAddr + u32ParamLen > FMC_FLASH_PAGE_SIZE )
		{
			u32ParamLen = FMC_FLASH_PAGE_SIZE - u32StartAddr;
		}

		MemCpy( hidData, ((uint8_t *)&DataFlash) + u32StartAddr, u32ParamLen );

		hidInDataPtr = hidData;
		hidStartInReport( u32ParamLen );
	}

	return 0;
}
开发者ID:Daveee10,项目名称:myevic,代码行数:28,代码来源:meusbd.c


示例17: Write

   virtual C_file::E_WRITE_STATUS Write(const void *mem, dword len){

                              //put into cache
      while(curr_pos+len > CACHE_SIZE){
         dword sz = CACHE_SIZE - curr_pos;
         MemCpy(cache+curr_pos, mem, sz);
         curr_pos += sz;
         (byte*&)mem += sz;
         len -= sz;
         C_file::E_WRITE_STATUS ws = WriteFlush();
         if(ws)
            return ws;
      }
      MemCpy(cache+curr_pos, mem, len);
      curr_pos += len;
      return C_file::WRITE_OK;
   }
开发者ID:turbanoff,项目名称:X-plore,代码行数:17,代码来源:C_file.cpp


示例18: ExpSgRMx

int ExpSgRMx(T_SgOps *SgOps, const int NewRMx[9])
{
  T_RTMx  SMx[1];

  MemCpy(SMx->s.R, NewRMx, 9);
  IntSetZero(SMx->s.T, 3);
  return ExpSgSMx(SgOps, SMx);
}
开发者ID:rwgk,项目名称:sglite,代码行数:8,代码来源:sggen.c


示例19: String_Join

/// <summary>
/// Construct a new String instance by concatenating many other strings together, with a glue string between them.
/// </summary>
/// <param name="glue">The glue string to insert between successive string instances.  This will not be
/// added to the start and end of the resulting string:  Only between strings.</param>
/// <param name="strs">The array of string instances to join to create the new string.</param>
/// <param name="numStrs">The number of string instances in the array.</param>
/// <returns>The new String instance.</returns>
String String_Join(const String glue, const String *strs, Int numStrs)
{
	Int length, dest, i;
	struct StringInt *str;
	Byte *newText;
	const Byte *glueText;
	Int glueLength;

	if (numStrs <= 0) return String_Empty;

	length = 0;
	for (i = 0; i < numStrs; i++)
	{
		length += ((const struct StringInt *)(strs[i]))->length;
	}
	length += (numStrs - 1) * ((const struct StringInt *)glue)->length;

	if (length <= 0) return String_Empty;

	str = GC_MALLOC_STRUCT(struct StringInt);
	if (str == NULL) Smile_Abort_OutOfMemory();
	newText = GC_MALLOC_TEXT(length);
	if (newText == NULL) Smile_Abort_OutOfMemory();

	str->length = length;
	str->text = newText;

	glueText = ((const struct StringInt *)glue)->text;
	glueLength = ((const struct StringInt *)glue)->length;

	MemCpy(newText, ((const struct StringInt *)(strs[0]))->text, ((const struct StringInt *)(strs[0]))->length);
	dest = ((const struct StringInt *)(strs[0]))->length;

	for (i = 1; i < numStrs; i++)
	{
		MemCpy(newText + dest, glueText, glueLength);
		dest += glueLength;
		MemCpy(newText + dest, ((const struct StringInt *)(strs[i]))->text, ((const struct StringInt *)(strs[i]))->length);
		dest += ((const struct StringInt *)(strs[i]))->length;
	}

	newText[length] = '\0';

	return (String)str;
}
开发者ID:orbitalbits,项目名称:smile,代码行数:53,代码来源:string_core.c


示例20: BootpRx

bool BootpRx(char *bootpHeader, short len){
	BOOTP_HEADER	*bhp = (BOOTP_HEADER *)bootpHeader;

	if (len!=BOOTP_HDR_SIZE)		return false;

	// check bootp.
	if (bhp->bh_opcode!=2)			return false;
	if (bhp->bh_htype!=1)			return false;
	if (bhp->bh_hlen!=6)			return false;
	if (MemCmp(&bhp->bh_tid, &bootpID, 4)) return false;
	if (MemCmp(&bhp->bh_chaddr, &clientEther, 6)) return false;

	// get infomation from bootp packet.
	MemCpy(&clientIP, &bhp->bh_yiaddr, 4);
	MemCpy(&hostIP  , &bhp->bh_siaddr, 4);

	bootpState = BOOTP_SUCCESS;
	return true;
}	// BootpRx.
开发者ID:ohunghun,项目名称:embedded,代码行数:19,代码来源:bootp.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ MemFree函数代码示例发布时间:2022-05-30
下一篇:
C++ MemCopy函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap