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


C++ xnew函数代码示例

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


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

示例1: jscoverage_bytes_to_characters

int jscoverage_bytes_to_characters(const char * encoding, const uint8_t * bytes, size_t num_bytes, jschar ** characters, size_t * num_characters) {
  assert(encoding != NULL);

  if (num_bytes == 0) {
    *characters = xnew(jschar, 0);
    *num_characters = 0;
    return 0;
  }

  UINT code_page;
  if (find_code_page(encoding, &code_page) != 0) {
    return JSCOVERAGE_ERROR_ENCODING_NOT_SUPPORTED;
  }

  if (num_bytes > INT_MAX) {
    fatal("overflow");
  }

  *characters = xnew(jschar, num_bytes);

  int result = MultiByteToWideChar(code_page, MB_ERR_INVALID_CHARS, bytes, num_bytes, *characters, num_bytes);
  if (result == 0) {
    free(*characters);
    return JSCOVERAGE_ERROR_INVALID_BYTE_SEQUENCE;
  }

  *num_characters = result;
  skip_bom(characters, num_characters);
  return 0;
}
开发者ID:Loen-ring,项目名称:jscoverage-1,代码行数:30,代码来源:encoding.c

示例2: krb_locate_kdc

KDCENTRY* krb_locate_kdc(rdpSettings* settings)
{
#ifdef WITH_RESOLV
	char *qname;
	int reslen, i;
	unsigned char response[4096];
	char kdc_host[4096];
	unsigned char* temp;
	KDCENTRY* head;
	KDCENTRY* kdcentry;
	KDCENTRY* srvans;
	ns_msg handle;
	ns_rr rr;
	head = kdcentry =  NULL;
	if (get_krb_realm(settings))
		return NULL;
	if (settings->kerberos_kdc)
	{
		srvans = xnew(KDCENTRY);
		srvans->kdchost = xstrdup(settings->kerberos_kdc);
		srvans->port = 88;
		return srvans;
	}
	qname = get_dns_queryname(settings->kerberos_realm, "_tcp.");

	if ((reslen = res_query(qname, ns_c_in, ns_t_srv, response, sizeof(response))) < 0)
		return NULL;

	ns_initparse(response, reslen, &handle);

	for (i = 0;i < ns_msg_count(handle, ns_s_an);i++)
	{
		ns_parserr(&handle, ns_s_an, i, &rr);
		srvans = xnew(KDCENTRY);
		temp = (unsigned char*)ns_rr_rdata(rr);
		GETUINT16(temp, &(srvans->priority));
		GETUINT16(temp, &(srvans->weight));
		GETUINT16(temp, &(srvans->port));
		if (ns_name_uncompress(ns_msg_base(handle), ns_msg_end(handle), temp, (char*)kdc_host, sizeof(kdc_host)) < 0)
			srvans->kdchost = xstrdup((const char*)temp);
		else
			srvans->kdchost = xstrdup(kdc_host);
		if (head == NULL || head->priority > srvans->priority)
		{
			srvans->next = head;
			head = srvans;
		}
		else
		{
			for (kdcentry = head;kdcentry->next != NULL && kdcentry->next->priority < srvans->priority;kdcentry = kdcentry->next);
			srvans->next = kdcentry->next;
			kdcentry->next = srvans;
		}
	}

	return head;
#else
	return NULL;
#endif
}
开发者ID:ArvidNorr,项目名称:FreeRDP,代码行数:60,代码来源:kerberos.c

示例3: svc_plugin_init

void svc_plugin_init(rdpSvcPlugin* plugin, CHANNEL_ENTRY_POINTS* pEntryPoints)
{
	rdpSvcPluginList* list;

	/**
	 * The channel manager will guarantee only one thread can call
	 * VirtualChannelInit at a time. So this should be safe.
	 */
	if (g_mutex == NULL)
		g_mutex = freerdp_mutex_new();

	memcpy(&plugin->channel_entry_points, pEntryPoints, pEntryPoints->cbSize);

	plugin->priv = xnew(rdpSvcPluginPrivate);

	/* Add it to the global list */
	list = xnew(rdpSvcPluginList);
	list->plugin = plugin;

	freerdp_mutex_lock(g_mutex);
	list->next = g_svc_plugin_list;
	g_svc_plugin_list = list;
	freerdp_mutex_unlock(g_mutex);

	plugin->channel_entry_points.pVirtualChannelInit(&plugin->priv->init_handle,
		&plugin->channel_def, 1, VIRTUAL_CHANNEL_VERSION_WIN2000, svc_plugin_init_event);
}
开发者ID:roman-b,项目名称:FreeRDP-1.0,代码行数:27,代码来源:svc_plugin.c

示例4: remmina_rdp_pre_connect

static boolean remmina_rdp_pre_connect(freerdp* instance)
{
	rfContext* rfi;
	rdpSettings* settings;
	RemminaProtocolWidget* gp;

	rfi = (rfContext*) instance->context;
	settings = instance->settings;
	gp = rfi->protocol_widget;

	settings->bitmap_cache = True;
	settings->offscreen_bitmap_cache = True;

	settings->order_support[NEG_DSTBLT_INDEX] = True;
	settings->order_support[NEG_PATBLT_INDEX] = True;
	settings->order_support[NEG_SCRBLT_INDEX] = True;
	settings->order_support[NEG_OPAQUE_RECT_INDEX] = True;
	settings->order_support[NEG_DRAWNINEGRID_INDEX] = False;
	settings->order_support[NEG_MULTIDSTBLT_INDEX] = False;
	settings->order_support[NEG_MULTIPATBLT_INDEX] = False;
	settings->order_support[NEG_MULTISCRBLT_INDEX] = False;
	settings->order_support[NEG_MULTIOPAQUERECT_INDEX] = True;
	settings->order_support[NEG_MULTI_DRAWNINEGRID_INDEX] = False;
	settings->order_support[NEG_LINETO_INDEX] = True;
	settings->order_support[NEG_POLYLINE_INDEX] = True;
	settings->order_support[NEG_MEMBLT_INDEX] = True;
	settings->order_support[NEG_MEM3BLT_INDEX] = False;
	settings->order_support[NEG_MEMBLT_V2_INDEX] = True;
	settings->order_support[NEG_MEM3BLT_V2_INDEX] = False;
	settings->order_support[NEG_SAVEBITMAP_INDEX] = False;
	settings->order_support[NEG_GLYPH_INDEX_INDEX] = True;
	settings->order_support[NEG_FAST_INDEX_INDEX] = True;
	settings->order_support[NEG_FAST_GLYPH_INDEX] = False;
	settings->order_support[NEG_POLYGON_SC_INDEX] = False;
	settings->order_support[NEG_POLYGON_CB_INDEX] = False;
	settings->order_support[NEG_ELLIPSE_SC_INDEX] = False;
	settings->order_support[NEG_ELLIPSE_CB_INDEX] = False;

	if (settings->rfx_codec == True)
	{
		settings->frame_acknowledge = False;
		settings->large_pointer = True;
		settings->performance_flags = PERF_FLAG_NONE;

		rfi->rfx_context = rfx_context_new();
		rfx_context_set_cpu_opt(rfi->rfx_context, CPU_SSE2);
	}

	freerdp_channels_pre_connect(rfi->channels, instance);

	rfi->clrconv = xnew(CLRCONV);
	rfi->clrconv->alpha = true;
	rfi->clrconv->invert = false;
	rfi->clrconv->rgb555 = false;
	rfi->clrconv->palette = xnew(rdpPalette);

	instance->context->cache = cache_new(instance->settings);

	return True;
}
开发者ID:edvillan15,项目名称:Remmina,代码行数:60,代码来源:rdp_plugin.c

示例5: output

static void output(avp_t *avp, const char *fn)
{
  FILE *fp;
  int i, j, id, m = 10, nm;
  double dvol, *fe, *pr, rho0, rho1, p;

  nm = avp->n * m;
  xnew(pr, avp->n*m + 1);
  xnew(fe, avp->n*m + 1);
  /* compute the free energy */
  fe[0] = 0;
  for (i = 0; i < avp->n; i++) {
    p = av_getave( &avp->av[i] );
    for (j = 0; j < m; j++) { /* add finer bins */
      rho0 = avp->rhomin + (i + 1.0*j/m) * avp->rhodel;
      rho1 = avp->rhomin + (i + 1.0*(j+1)/m) * avp->rhodel;
      dvol = avp->np/rho1 - avp->np/rho0;
      id = i*m + j;
      pr[id] = p;
      fe[id + 1] = fe[id] - pr[id] * dvol;
    }
  }
  pr[nm] = pr[nm-1];

  xfopen(fp, fn, "w", return);
  for (i = 0; i <= nm; i++) {
    rho0 = avp->rhomin + i * avp->rhodel/m;
    fprintf(fp, "%g %g %g\n", rho0, fe[i], pr[i]);
  }
  fclose(fp);
  free(pr);
  free(fe);
}
开发者ID:3ki5tj,项目名称:tstat,代码行数:33,代码来源:volrw.c

示例6: main

int main(int argc, char **argv)
{
  model_t m[1];
  hist_t *hs;
  double *beta, *lnz;
  int iT;
  unsigned flags = 0;

  model_default_lj(m);
  model_doargs(m, argc, argv);
  if ( m->rmcom ) flags |= WHAM_RMCOM;

  xnew(beta, m->nT);
  xnew(lnz, m->nT);
  for ( iT = 0; iT < m->nT; iT++ ) {
    beta[iT] = 1./(m->Tmin + m->Tdel * iT);
    lnz[iT] = 0;
  }

  if ( m->loadprev ) {
    /* load from existing histogram */
    if ( (hs = hist_initf(m->fnhis, HIST_INT | HIST_VERBOSE)) == NULL ) {
      return -1;
    }
  } else {
    if ( m->simul == SIMUL_MD ) {
      hs = lj_domd(m, beta);
    } else {
      hs = lj_domc(m, beta);
    }
  }

  whamx(hs, beta, lnz, flags, NULL,
      m->damp, m->mdiis_nbases,
      m->mdiis_update_method, m->mdiis_threshold,
      m->itmin, m->itmax, m->tol, m->verbose,
      m->fnlndos, m->fneav, m->wham_method);

  if ( m->verbose ) {
    double lnzref0 = 0;

    for ( iT = 0; iT < hs->rows; iT++ ) {
      double tp = 1/beta[iT], tot, eav, var;
      double eref, pref, lnzref, muref;

      eav = hist_getave(hs, iT, &tot, &var);
      eref = ljeos3d_get(m->rho, tp, &pref, &lnzref, &muref);
      lnzref *= -m->nn / tp;
      if ( iT == 0 ) lnzref0 = lnzref;
      printf("%3d %10.7f %14.7f %8.0f %15.7f %14.7f | %10.3f %10.3f\n",
          iT, tp, lnz[iT], tot, eav, sqrt(var),
          lnzref - lnzref0, eref * m->nn);
    }
  }

  hist_close(hs);
  free(beta);
  free(lnz);
  return 0;
}
开发者ID:3ki5tj,项目名称:wham,代码行数:60,代码来源:ljwham.c

示例7: run

/* entropic sampling */
static int run(ising_t *is, double trun)
{
  algei_t *al;
  double t, *ehis, verr[8], ave2 = 0, alf = 0;
  int it = 0, u0 = 0, u1, du = 0;
  int *stack, nstack = 0;

  xnew(stack, seglen);

  al = algei_open(epmin, epmax, epdel, beta0, beta1);
  /* equilibrate the system till is->E > epmin */
  for (t = 1; is->E <= epmin + 4; t++) {
    int id, h;
    IS2_PICK(is, id, h);
    IS2_FLIP(is, id, h);
  }
  printf("equilibration finished in %d steps\n", it);

  xnew(ehis, ECNT);

  u0 = is->E;

  for (t = 1; t <= trun; t++) {
    ehis[ (is->E - EMIN)/EDEL ] += 1;
    move(is, al, stack, &nstack);

    if (++it % seglen == 0) {
      u1 = is->E;
      du = u1 - u0;
      assert(u0 >= epmin && u0 < epmax);
      algei_fupdate(al, u0, du, alf0, alfc, &alf,
          delmax, &ave2, 0, betmax);
      if (u1 < epmin || u1 >= epmax) { /* undo out-of-boudary segments */
        undo(is, stack, nstack);
        u1 = is->E;
      }
      u0 = u1; /* set the new start point */
      nstack = 0; /* clear the stack */

      if (it % nevery == 0) {
        printf("t %g, ep %d, du %d, e2 %g, alf %g\n", t, is->E, du, ave2, alf);
      }

      if (it % nreport == 0 || t >= nsteps - .1) {
        saveall(al, is->logdos, verr, ehis, fnhis);
        printf("trun %g, eabsave %g, eabsmax %g, erelave %g, erelmax %g\n",
          trun, verr[0], verr[1], verr[2], verr[3]);
        algei_save(al, fnout);
        it = 0; /* reset the integer counter */
      }
    }
  }
  algei_close(al);
  free(ehis);
  free(stack);
  return 0;
}
开发者ID:3ki5tj,项目名称:alge,代码行数:58,代码来源:is1.c

示例8: rpc_client_virtual_connection_new

RpcVirtualConnection* rpc_client_virtual_connection_new(rdpRpc* rpc)
{
	RpcVirtualConnection* virtual_connection = xnew(RpcVirtualConnection);

	if (virtual_connection != NULL)
	{
		virtual_connection->State = VIRTUAL_CONNECTION_STATE_INITIAL;
		virtual_connection->DefaultInChannel = xnew(RpcInChannel);
		virtual_connection->DefaultOutChannel = xnew(RpcOutChannel);
		rpc_client_virtual_connection_init(rpc, virtual_connection);
	}

	return virtual_connection;
}
开发者ID:felfert,项目名称:FreeRDP,代码行数:14,代码来源:rpc.c

示例9: FreeRDPRdpsndDeviceEntry

int FreeRDPRdpsndDeviceEntry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pEntryPoints)
{
	rdpsndAudioQPlugin* aqPlugin;
	RDP_PLUGIN_DATA* data;
    
	aqPlugin = xnew(rdpsndAudioQPlugin);

	aqPlugin->device.Open = rdpsnd_audio_open;
	aqPlugin->device.FormatSupported = rdpsnd_audio_format_supported;
	aqPlugin->device.SetFormat = rdpsnd_audio_set_format;
	aqPlugin->device.SetVolume = rdpsnd_audio_set_volume;
	aqPlugin->device.Play = rdpsnd_audio_play;
	aqPlugin->device.Start = rdpsnd_audio_start;
	aqPlugin->device.Close = rdpsnd_audio_close;
	aqPlugin->device.Free = rdpsnd_audio_free;

	data = pEntryPoints->plugin_data;
    
	if (data && strcmp((char *)data->data[0], "macaudio") == 0) {
		if(strlen((char *)data->data[1]) > 0)
			aqPlugin->device_name = strdup((char *)data->data[1]);
		else
			aqPlugin->device_name = NULL;
	}
	pEntryPoints->pRegisterRdpsndDevice(pEntryPoints->rdpsnd, (rdpsndDevicePlugin*)aqPlugin);
	return 0;
}
开发者ID:5m3ntarios,项目名称:FreeRDP,代码行数:27,代码来源:rdpsnd_mac.c

示例10: crypto_kdcmsg_decrypt_rc4

rdpBlob* crypto_kdcmsg_decrypt_rc4(rdpBlob* msg, uint8* key, uint32 msgtype)
{
	rdpBlob* decmsg;
	uint8* K1;
	uint8* K3;
	uint32 len;
	krbEdata* edata;
	CryptoRc4 rc4;
	K1 = xzalloc(16);
	K3 = xzalloc(16);
	len = msg->length;
	edata = xzalloc(len);
	HMAC(EVP_md5(), (void*) key, 16, (uint8*) &msgtype, 4, (void*) K1, NULL);
	HMAC(EVP_md5(), (void*) K1, 16, (uint8*) msg->data , 16, (void*) K3, NULL);
	rc4 = crypto_rc4_init(K3, 16);
	crypto_rc4(rc4, len - 16, (uint8*)(((uint8*) msg->data) + 16), (uint8*) edata->Confounder);
	crypto_rc4_free(rc4);
	HMAC(EVP_md5(), (void*) K1, 16, (uint8*)edata->Confounder, len - 16, (void*)&(edata->Checksum), NULL);
	if(memcmp(msg->data, &edata->Checksum, 16))
	{
		xfree(edata) ;
		xfree(K1) ;
		xfree(K3) ;
		return NULL;
	}
	decmsg = xnew(rdpBlob);
	freerdp_blob_alloc(decmsg, len);
	memcpy(decmsg->data, edata, len);
	xfree(K1);
	xfree(K3);
	xfree(edata);
	return decmsg;
}
开发者ID:littlejawa,项目名称:FreeRDP,代码行数:33,代码来源:kerberos_crypto.c

示例11: crypto_kdcmsg_encrypt_rc4

rdpBlob* crypto_kdcmsg_encrypt_rc4(rdpBlob* msg, uint8* key, uint32 msgtype)
{
	rdpBlob* encmsg;
	uint8* K1;
	uint8* K3;
	uint32 len;
	krbEdata* edata;
	CryptoRc4 rc4;
	K1 = xzalloc(16);
	K3 = xzalloc(16);
	len = ((msg->length > 16) ? msg->length : 16);
	len += sizeof(krbEdata);
	edata = xzalloc(len);
	encmsg = xnew(rdpBlob);
	freerdp_blob_alloc(encmsg, len);
	HMAC(EVP_md5(), (void*) key, 16, (uint8*)&msgtype, 4, (void*) K1, NULL);
	crypto_nonce((uint8*)(edata->Confounder), 8);
	memcpy(&(edata->data[0]), msg->data, msg->length);
	HMAC(EVP_md5(), (void*) K1, 16, (uint8*)edata->Confounder, len - 16, (void*)&(edata->Checksum), NULL);
	HMAC(EVP_md5(), (void*) K1, 16, (uint8*)&(edata->Checksum), 16, (void*)K3, NULL);
	memcpy(encmsg->data, &(edata->Checksum), 16);
	rc4 = crypto_rc4_init(K3, 16);
	crypto_rc4(rc4, len - 16, (uint8*) edata->Confounder, (uint8*)(((uint8*) encmsg->data) + 16));
	crypto_rc4_free(rc4);
	xfree(K1);
	xfree(K3);
	xfree(edata);
	return encmsg;
}
开发者ID:littlejawa,项目名称:FreeRDP,代码行数:29,代码来源:kerberos_crypto.c

示例12: SteepestDescent

void SteepestDescent (Vector & x, const MinFunction & fun,
		      const OptiParameters & par)
{
  int it, n = x.Size();
  Vector xnew(n), p(n), g(n), g2(n);
  double val, alphahat;
  int fail;

  val = fun.FuncGrad(x, g);

  alphahat = 1;
  //  testout << "f = ";
  for (it = 0; it < 10; it++)
    {
      //    testout << val << " ";

      // p = -g;
      p.Set (-1, g);

      lines (x, xnew, p, val, g, fun, par, alphahat, -1e5,
	     0.1, 0.1, 1, 10, 0.1, 0.1, 0.6, fail);

      x = xnew;
    }
  //  testout << endl;
}
开发者ID:AlexanderToifl,项目名称:viennamesh-dev,代码行数:26,代码来源:linsearch.cpp

示例13: xnew

void *Blocktype_newf(size_t elsize)
{
	Blocktype *b = xnew(Blocktype);
	b->elsize = max(elsize, sizeof(void *));
	b->free = 0;
	return (void *)b;
}
开发者ID:hroptatyr,项目名称:sxemacs,代码行数:7,代码来源:blocktype.c

示例14: krb_apreq_new

KrbAPREQ* krb_apreq_new(KRB_CONTEXT* krb_ctx, Ticket* ticket, Authenticator* krb_auth)
{
	KrbAPREQ* krb_apreq;
	STREAM* as;
	rdpBlob msg;
	rdpBlob* encmsg;
	uint32 len;

	as = stream_new(1024);
	stream_seek(as, 1023);

	krb_apreq = xnew(KrbAPREQ);
	krb_apreq->pvno = KRB_VERSION;
	krb_apreq->type = KRB_TAG_APREQ;
	krb_apreq->ap_options = 0x00000000 | 0x00000000 | 0x00000000; /* Reserved (bit 31), Use session Key (bit 30), Mututal Required (bit 29) */
	krb_apreq->ticket = ticket;

	if (krb_auth != NULL)
	{
		len = krb_encode_authenticator(as, krb_auth);
		msg.data = as->p;
		msg.length = len;
		encmsg = crypto_kdcmsg_encrypt(&msg, krb_ctx->askey, 7); /* RFC4757 section 3 for msgtype (T=7) */
		krb_apreq->enc_auth.enctype = krb_ctx->askey->enctype;
		krb_apreq->enc_auth.kvno = -1;
		krb_apreq->enc_auth.encblob.data = encmsg->data;
		krb_apreq->enc_auth.encblob.length =  encmsg->length;
		xfree(encmsg);
	}
	
	stream_free(as);
	
	return krb_apreq;
}
开发者ID:ArvidNorr,项目名称:FreeRDP,代码行数:34,代码来源:kerberos.c

示例15: xnew

Node *Node_new(int key, int value)
{
  Node *self= xnew(Node);
  self->key= key;
  self->value= value;
  return self;
}
开发者ID:6a6enb,项目名称:libsynctory,代码行数:7,代码来源:test.c


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