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


C++ MEMCPY函数代码示例

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


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

示例1: fiber_init

static VALUE
fiber_init(VALUE fibval, VALUE proc)
{
    rb_fiber_t *fib = fiber_t_alloc(fibval);
    rb_context_t *cont = &fib->cont;
    rb_thread_t *th = &cont->saved_thread;

    fiber_link_join(fib);

    /* initialize cont */
    cont->vm_stack = 0;

    th->stack = 0;
    th->stack_size = FIBER_VM_STACK_SIZE;
    th->stack = ALLOC_N(VALUE, th->stack_size);

    th->cfp = (void *)(th->stack + th->stack_size);
    th->cfp--;
    th->cfp->pc = 0;
    th->cfp->sp = th->stack + 1;
    th->cfp->bp = 0;
    th->cfp->lfp = th->stack;
    *th->cfp->lfp = 0;
    th->cfp->dfp = th->stack;
    th->cfp->self = Qnil;
    th->cfp->flag = 0;
    th->cfp->iseq = 0;
    th->cfp->proc = 0;
    th->cfp->block_iseq = 0;
    th->tag = 0;
    th->local_storage = st_init_numtable();

    th->first_proc = proc;

    MEMCPY(&cont->jmpbuf, &th->root_jmpbuf, rb_jmpbuf_t, 1);

    return fibval;
}
开发者ID:3runo5ouza,项目名称:rhodes,代码行数:38,代码来源:cont.c

示例2: init_machine

/**
 * Initialize virtual machine state prior to executing vertex program.
 */
static void
init_machine(GLcontext *ctx, struct gl_program_machine *machine)
{
   /* Input registers get initialized from the current vertex attribs */
   MEMCPY(machine->VertAttribs, ctx->Current.Attrib,
          MAX_VERTEX_PROGRAM_ATTRIBS * 4 * sizeof(GLfloat));

   if (ctx->VertexProgram._Current->IsNVProgram) {
      GLuint i;
      /* Output/result regs are initialized to [0,0,0,1] */
      for (i = 0; i < MAX_NV_VERTEX_PROGRAM_OUTPUTS; i++) {
         ASSIGN_4V(machine->Outputs[i], 0.0F, 0.0F, 0.0F, 1.0F);
      }
      /* Temp regs are initialized to [0,0,0,0] */
      for (i = 0; i < MAX_NV_VERTEX_PROGRAM_TEMPS; i++) {
         ASSIGN_4V(machine->Temporaries[i], 0.0F, 0.0F, 0.0F, 0.0F);
      }
      for (i = 0; i < MAX_VERTEX_PROGRAM_ADDRESS_REGS; i++) {
         ASSIGN_4V(machine->AddressReg[i], 0, 0, 0, 0);
      }
   }

   machine->NumDeriv = 0;

   /* init condition codes */
   machine->CondCodes[0] = COND_EQ;
   machine->CondCodes[1] = COND_EQ;
   machine->CondCodes[2] = COND_EQ;
   machine->CondCodes[3] = COND_EQ;

   /* init call stack */
   machine->StackDepth = 0;

   machine->FetchTexelLod = vp_fetch_texel;
   machine->FetchTexelDeriv = NULL; /* not used by vertex programs */

   machine->Samplers = ctx->VertexProgram._Current->Base.SamplerUnits;
}
开发者ID:Multi2Sim,项目名称:m2s-bench-parsec-3.0-src,代码行数:41,代码来源:t_vb_program.c

示例3: meta_load_sysindex

int
meta_load_sysindex(char *sysindex)
{
	int	fd;
	char	tab_meta_dir[TABLE_NAME_MAX_LEN];
	int	status;
	int	rtn_stat;


	rtn_stat= TRUE;
	
	
	MEMSET(tab_meta_dir, 256);
	MEMCPY(tab_meta_dir, MT_META_INDEX, STRLEN(MT_META_INDEX));
	str1_to_str2(tab_meta_dir, '/', "sysindex");

	OPEN(fd, tab_meta_dir, (O_RDONLY));

	if (fd < 0)
	{
		return FALSE;
	}

	status = READ(fd, sysindex, sizeof(META_SYSINDEX));

	Assert(status == sizeof(META_SYSINDEX));

	if (status != sizeof(META_SYSINDEX))
	{
		traceprint("Save sysindex hit error!\n");
		rtn_stat = FALSE;
		
	}

	CLOSE(fd);

	return rtn_stat;
}
开发者ID:teodor-pripoae,项目名称:maxtable,代码行数:38,代码来源:metadata.c

示例4: convIpStrToIpAddr

IpAddr convIpStrToIpAddr(const S8* pIp, U32 len)
{
   LOG_ENTERFN();

   IpAddr ipAddr;
   S8     ip[GSIM_SIZE_32] = {'\0'};
   MEMCPY(ip, pIp, len);

   ipAddr.ipAddrType = IP_ADDR_TYPE_INV;
   if (STRFIND(ip, ":") != NULL)
   {
      RETVAL ret = inet_pton(AF_INET6, ip, (VOID *)(ipAddr.u.ipv6Addr.addr));
      if (0 == ret)
      {
         LOG_FATAL("Invalid IPv6 Address");
      }
      else
      {
         ipAddr.u.ipv6Addr.len = STRLEN(ip);
         ipAddr.ipAddrType = IP_ADDR_TYPE_V6;
      }
   }
   else
   {
      RETVAL ret = inet_pton(AF_INET, ip, (VOID *)&(ipAddr.u.ipv4Addr.addr));
      if (0 == ret)
      {
         LOG_FATAL("Invalid IPv4 Address");
      }
      else
      {
         ipAddr.u.ipv4Addr.addr = ntohl(ipAddr.u.ipv4Addr.addr);
         ipAddr.ipAddrType = IP_ADDR_TYPE_V4;
      }
   }

   LOG_EXITFN(ipAddr);
}
开发者ID:2fumin,项目名称:LTE-GTP-Simulator,代码行数:38,代码来源:gtp_util.cpp

示例5: OmegaUdpCreate

int OmegaUdpCreate(char *HostDnsName, int UdpPort)
{
	struct hostent *host; 
	struct sockaddr_in sa; 
	char IpAddr[20];
	
	if ((host = (struct hostent *)S_GETHOSTBYNAME(HostDnsName)) == NULL) //根据域名获取相应的IP信息, host将包含@remote_host对应的IP信息 
	{ 
		//libc_printf("----S_GETHOSTBYNAME Host name %s error! ----\r\n",HostDnsName);
	  return -1; 
	} 
	MEMCPY(&sa.sin_addr, host->h_addr, host->h_length);
	MEMSET(IpAddr,0,20);
	STRCPY(IpAddr,inet_ntoa(sa.sin_addr));
	//libc_printf("--Found omega,RAW  address:%s\n",inet_ntoa(sa.sin_addr)); 
	//libc_printf("--Found omega,IpAddr  address:%s\n",IpAddr);
	sock = socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
	memset(&servaddr,0,sizeof(servaddr));
	servaddr.sin_family=AF_INET;
	servaddr.sin_addr.s_addr=inet_addr(IpAddr);
	servaddr.sin_port = htons(UdpPort);
	return sock;
}
开发者ID:alkap007,项目名称:ali3606,代码行数:23,代码来源:dmtcpipapi.c

示例6: grpc_rb_server_credentials_init_copy

/* Clones ServerCredentials instances.

   Gives ServerCredentials a consistent implementation of Ruby's object copy/dup
   protocol. */
static VALUE grpc_rb_server_credentials_init_copy(VALUE copy, VALUE orig) {
  grpc_rb_server_credentials *orig_ch = NULL;
  grpc_rb_server_credentials *copy_ch = NULL;

  if (copy == orig) {
    return copy;
  }

  /* Raise an error if orig is not a server_credentials object or a subclass. */
  if (TYPE(orig) != T_DATA ||
      RDATA(orig)->dfree != (RUBY_DATA_FUNC)grpc_rb_server_credentials_free) {
    rb_raise(rb_eTypeError, "not a %s",
             rb_obj_classname(rb_cServerCredentials));
  }

  Data_Get_Struct(orig, grpc_rb_server_credentials, orig_ch);
  Data_Get_Struct(copy, grpc_rb_server_credentials, copy_ch);

  /* use ruby's MEMCPY to make a byte-for-byte copy of the server_credentials
     wrapper object. */
  MEMCPY(copy_ch, orig_ch, grpc_rb_server_credentials, 1);
  return copy;
}
开发者ID:Abioy,项目名称:kythe,代码行数:27,代码来源:rb_server_credentials.c

示例7: tls_cmd_set_default_socket_params

int tls_cmd_set_default_socket_params(
        struct tls_cmd_socket_t *params, u8 update_flash)
{
    struct tls_socket_cfg  *skt_cfg = &socket_cfg;
	struct tls_param_socket param_socket_cfg;
    if(tls_param_get_updp_mode()==0)
    {
	    skt_cfg->proto = params->proto;
	    skt_cfg->client = params->client;
	    skt_cfg->port = params->port;
	   	skt_cfg->host_len = params->host_len;  
	    MEMCPY(skt_cfg->ip_addr, params->ip_addr, 4);
		strcpy((char *)skt_cfg->host, params->host_name);
	    skt_cfg->timeout = params->timeout;
    }
    param_socket_cfg.client_or_server = params->client ? 0 : 1;
    param_socket_cfg.protocol = params->proto;
    param_socket_cfg.port_num = params->port;
   	strcpy((char *)param_socket_cfg.host, params->host_name);
    tls_param_set(TLS_PARAM_ID_DEFSOCKET, (void *)&param_socket_cfg,
            (bool)update_flash);
    return 0;
}
开发者ID:sdhczw,项目名称:winnermicro,代码行数:23,代码来源:wm_cmdp.c

示例8: free

void AnsiString::operator=(const AnsiString& S) {
    size_t len;

    if (Data)
        Data[0] = 0;
    _LENGTH = 0;

    char *other_data = S.c_str();
    len = S._LENGTH;
    if (len) {
        _LENGTH = len;
        if (len + 1 >= _DATA_SIZE) {
            /*if (Data)
             *  delete[] Data;*/
            free(Data);
            _DATA_SIZE = ((len + 1) / BLOCK_SIZE) * BLOCK_SIZE + BLOCK_SIZE;
            //Data=new char[_DATA_SIZE];
            Data = (char *)malloc(_DATA_SIZE);
        }
        MEMCPY(Data, other_data, len + 1);
        //Data[len]=0;
    }
}
开发者ID:Devronium,项目名称:ConceptApplicationServer,代码行数:23,代码来源:AnsiString.cpp

示例9: grpc_rb_channel_init_copy

/* Clones Channel instances.

   Gives Channel a consistent implementation of Ruby's object copy/dup
   protocol. */
static VALUE grpc_rb_channel_init_copy(VALUE copy, VALUE orig) {
  grpc_rb_channel *orig_ch = NULL;
  grpc_rb_channel *copy_ch = NULL;

  if (copy == orig) {
    return copy;
  }

  /* Raise an error if orig is not a channel object or a subclass. */
  if (TYPE(orig) != T_DATA ||
      RDATA(orig)->dfree != (RUBY_DATA_FUNC)grpc_rb_channel_free) {
    rb_raise(rb_eTypeError, "not a %s", rb_obj_classname(grpc_rb_cChannel));
    return Qnil;
  }

  TypedData_Get_Struct(orig, grpc_rb_channel, &grpc_channel_data_type, orig_ch);
  TypedData_Get_Struct(copy, grpc_rb_channel, &grpc_channel_data_type, copy_ch);

  /* use ruby's MEMCPY to make a byte-for-byte copy of the channel wrapper
   * object. */
  MEMCPY(copy_ch, orig_ch, grpc_rb_channel, 1);
  return copy;
}
开发者ID:FabioBatSilva,项目名称:grpc,代码行数:27,代码来源:rb_channel.c

示例10: sp_playlist_add_tracks

sp_error
sp_playlist_add_tracks(sp_playlist *playlist, sp_track *const *tracks, int num_tracks, int position, sp_session *session)
{
  int size = sp_playlist_num_tracks(playlist);
  int new_size = size + num_tracks;
  int i, j, k;
  sp_playlist_track_t *new_tracks = NULL;

  if (position < 0 || position > size)
  {
    return SP_ERROR_INVALID_INDATA;
  }

  new_tracks = ALLOC_N(sp_playlist_track_t, new_size);

  for (i = 0, j = 0, k = 0; i < new_size; ++i)
  {
    if (i >= position && j < num_tracks)
    {
      new_tracks[i].track = tracks[j++];
      new_tracks[i].create_time = (int) time(NULL); // let’s hope before year 2038 we fix this :)
      new_tracks[i].creator = sp_session_user(session);
      new_tracks[i].message = NULL;
      new_tracks[i].seen = true;
    }
    else
    {
      MEMCPY(&new_tracks[i], &playlist->tracks[k++], sp_playlist_track_t);
    }
  }

  free(playlist->tracks);
  playlist->tracks = new_tracks;
  playlist->num_tracks = new_size;

  return SP_ERROR_OK;
}
开发者ID:Burgestrand,项目名称:libmockspotify,代码行数:37,代码来源:playlist.c

示例11: update_player_states

int update_player_states(play_para_t *para, int force)
{
    callback_t *cb = &para->update_state;
    update_state_fun_t fn;
    para->state.last_sta = para->state.status;
    para->state.status = get_player_state(para);

    if (check_time_interrupt(&cb->callback_old_time, cb->update_interval) || force) {
        player_info_t state;
        MEMCPY(&state, &para->state, sizeof(state));
        //if(force == 1)
        log_print("**[update_state]pid:%d status=%s(tttlast:%s) err=0x%x curtime=%d (ms:%d) fulltime=%d lsttime=%d\n",
                  para->player_id,
                  player_status2str(state.status),
                  player_status2str(state.last_sta),
                  (-state.error_no),
                  state.current_time,
                  state.current_ms,
                  state.full_time,
                  state.last_time);		
        log_print("**[update_state]abuflevel=%.08f vbublevel=%.08f abufrp=%x vbufrp=%x read_end=%d\n",
                  state.audio_bufferlevel,
                  state.video_bufferlevel,
                  para->abuffer.buffer_rp,
                  para->vbuffer.buffer_rp,
                  para->playctrl_info.read_end_flag);
        fn = cb->update_statue_callback;

        if (fn) {
            fn(para->player_id, &state);
        }
        send_event(para, PLAYER_EVENTS_PLAYER_INFO, &state, 0);
        para->state.error_no = 0;
        player_hwbuflevel_update(para);
    }
	return 0;
}
开发者ID:gzmorell,项目名称:buildroot,代码行数:37,代码来源:message.c

示例12: rtp_send_packets

/**
 * RTP send packets
 */
static void
rtp_send_packets( int sock, struct sockaddr_in* to)
{
  struct rtp_hdr* rtphdr;
  u8_t*           rtp_payload;
  int             rtp_payload_size;
  size_t          rtp_data_index;

  /* prepare RTP packet */
  rtphdr = (struct rtp_hdr*)rtp_send_packet;
  rtphdr->version     = RTP_VERSION;
  rtphdr->payloadtype = 0;
  rtphdr->ssrc        = PP_HTONL(RTP_SSRC);
  rtphdr->timestamp   = lwip_htonl(lwip_ntohl(rtphdr->timestamp) + RTP_TIMESTAMP_INCREMENT);

  /* send RTP stream packets */
  rtp_data_index = 0;
  do {
    rtp_payload      = rtp_send_packet+sizeof(struct rtp_hdr);
    rtp_payload_size = LWIP_MIN(RTP_PAYLOAD_SIZE, (sizeof(rtp_data) - rtp_data_index));

    MEMCPY(rtp_payload, rtp_data + rtp_data_index, rtp_payload_size);

    /* set MARKER bit in RTP header on the last packet of an image */
    rtphdr->payloadtype = RTP_PAYLOADTYPE | (((rtp_data_index + rtp_payload_size)
      >= sizeof(rtp_data)) ? RTP_MARKER_MASK : 0);

    /* send RTP stream packet */
    if (sendto(sock, rtp_send_packet, sizeof(struct rtp_hdr) + rtp_payload_size,
        0, (struct sockaddr *)to, sizeof(struct sockaddr)) >= 0) {
      rtphdr->seqNum  = lwip_htons(lwip_ntohs(rtphdr->seqNum) + 1);
      rtp_data_index += rtp_payload_size;
    } else {
      LWIP_DEBUGF(RTP_DEBUG, ("rtp_sender: not sendto==%i\n", errno));
    }
  }while (rtp_data_index < sizeof(rtp_data));
}
开发者ID:NCTU-ivan,项目名称:embarc_osp,代码行数:40,代码来源:rtp.c

示例13: of_wire_buffer_replace_data

void
of_wire_buffer_replace_data(of_wire_buffer_t *wbuf,
                            int offset,
                            int old_len,
                            uint8_t *data,
                            int new_len)
{
    int bytes;
    uint8_t *src_ptr, *dst_ptr;
    int cur_bytes;

    ASSERT(wbuf != NULL);

    cur_bytes = wbuf->current_bytes;

    /* Doesn't make sense; mismatch in current buffer info */
    ASSERT(old_len + offset <= wbuf->current_bytes);

    if (old_len < new_len) {
        of_wire_buffer_grow(wbuf, offset + new_len);
    } else {
        wbuf->current_bytes += (new_len - old_len); // may decrease size
    }

    if ((old_len + offset < cur_bytes) && (old_len != new_len)) {
        /* Need to move back of buffer */
        src_ptr = &wbuf->buf[offset + old_len];
        dst_ptr = &wbuf->buf[offset + new_len];
        bytes = cur_bytes - (offset + old_len);
        MEMMOVE(dst_ptr, src_ptr, bytes);
    }

    dst_ptr = &wbuf->buf[offset];
    MEMCPY(dst_ptr, data, new_len);

    ASSERT(wbuf->current_bytes == cur_bytes + (new_len - old_len));
}
开发者ID:amertahir,项目名称:indigo,代码行数:37,代码来源:of_wire_buf.c

示例14: system_set_value

static snmp_err_t 
system_set_value(const struct snmp_scalar_array_node_def *node, u16_t len, void *value)
{
  u8_t*  var_wr = NULL;
  u16_t* var_wr_len;

  switch (node->oid) {
  case 4: /* sysContact */
    var_wr     = syscontact_wr;
    var_wr_len = syscontact_wr_len;
    break;
  case 5: /* sysName */
    var_wr     = sysname_wr;
    var_wr_len = sysname_wr_len;
    break;
  case 6: /* sysLocation */
    var_wr     = syslocation_wr;
    var_wr_len = syslocation_wr_len;
    break;
  default:
    LWIP_DEBUGF(SNMP_MIB_DEBUG,("system_set_value(): unknown id: %"S32_F"\n", node->oid));
    return SNMP_ERR_GENERROR;
  }

  /* no need to check size of target buffer, this was already done in set_test method */
  LWIP_ASSERT("", var_wr != NULL);
  MEMCPY(var_wr, value, len);
  
  if (var_wr_len == NULL) {
    /* add terminating 0 */
    var_wr[len] = 0;
  } else {
    *var_wr_len = len;
  }

  return SNMP_ERR_NOERROR;
}
开发者ID:netsec-ethz,项目名称:scion-lwip,代码行数:37,代码来源:snmp_mib2_system.c

示例15: ChallengeResponse

static void ChallengeResponse(const u_char *challenge,
		  const u_char PasswordHash[MD4_SIGNATURE_SIZE],
		  u_char response[24]) {
    u_char    ZPasswordHash[21];
    lwip_des_context des;
    u_char des_key[8];

    BZERO(ZPasswordHash, sizeof(ZPasswordHash));
    MEMCPY(ZPasswordHash, PasswordHash, MD4_SIGNATURE_SIZE);

#if 0
    dbglog("ChallengeResponse - ZPasswordHash %.*B",
	   sizeof(ZPasswordHash), ZPasswordHash);
#endif

    pppcrypt_56_to_64_bit_key(ZPasswordHash + 0, des_key);
    lwip_des_init(&des);
    lwip_des_setkey_enc(&des, des_key);
    lwip_des_crypt_ecb(&des, challenge, response +0);
    lwip_des_free(&des);

    pppcrypt_56_to_64_bit_key(ZPasswordHash + 7, des_key);
    lwip_des_init(&des);
    lwip_des_setkey_enc(&des, des_key);
    lwip_des_crypt_ecb(&des, challenge, response +8);
    lwip_des_free(&des);

    pppcrypt_56_to_64_bit_key(ZPasswordHash + 14, des_key);
    lwip_des_init(&des);
    lwip_des_setkey_enc(&des, des_key);
    lwip_des_crypt_ecb(&des, challenge, response +16);
    lwip_des_free(&des);

#if 0
    dbglog("ChallengeResponse - response %.24B", response);
#endif
}
开发者ID:0xc0170,项目名称:mbed,代码行数:37,代码来源:lwip_chap_ms.c


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