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

C++ MGET函数代码示例

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

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



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

示例1: K_isMstable_coplanar

/**
 * This function implements the stability criterion of Mardling, 2008a for coplanar,
 * three body systems. 
 * @param alle A matrix of _all_ elements in hierarchical coordinates, as 
 * returned by K_getAllElements_jacobi (or supplied by the user).
 * 
 * @return One of T_INAPPLICABLE, T_STABLE or T_UNSTABLE. The routine returns T_INAPPLICABLE
 * if one of the following is true: (1) the system contains more of three bodies (returns
 * T_STABLE if two-body system); (2) the mass conditions for which n:1 resonances dominate
 * (m_2/m_1 > 0.01 && m_2/m_1 > 0.01 or m_2/m1 > 0.05 || m_3/m_1 > 0.05). The routine returns 
 * T_UNSTABLE if the stability criterion (E_n < 0 and E_(n+1) < 0) is satisfied,
 * T_STABLE otherwise.
 */
int K_isMstable_coplanar(const gsl_matrix* alle) {
    
    if (MROWS(alle) > 3)
        return T_INAPPLICABLE;
    
    if (MROWS(alle) == 2)
        return T_STABLE;
    
    double m_1 = MSUN_TO_MJUP(MGET(alle, 0, MASS));
    double m_2 = MGET(alle, 1, MASS);
    double m_3 = MGET(alle, 2, MASS);
    
    // outside mass criterion
    if ((m_2 / m_1 < 0.01 || m_3 / m_1 < 0.01) && (m_2 / m_1 < 0.05 && m_3 / m_1 < 0.05))
        return T_INAPPLICABLE;
    
    // Elements of inner and outer binary
    double P_i = MGET(alle, 1, PER);
    double P_o = MGET(alle, 2, PER);
    double sigma = P_o/P_i;
    double n = floor(sigma);
    
    double E_n = K_E_n(alle, n, sigma);
    double E_n1 = K_E_n(alle, n+1, sigma);
    
    if (E_n < 0 && E_n1 < 0)
        return T_UNSTABLE;
    else
        return T_STABLE;
}
开发者ID:ArtTucker,项目名称:Systemic2,代码行数:43,代码来源:extras.c


示例2: gss_verify_mic

OM_uint32
gss_verify_mic(OM_uint32 *minor_status,
               const gss_ctx_id_t ctx,
               const gss_buffer_t message_buffer,
               const gss_buffer_t token_buffer,
               gss_qop_t *qop_state)
{
    OM_uint32 maj_stat;
    struct mbuf *m, *mic;

    if (!ctx) {
        *minor_status = 0;
        return (GSS_S_NO_CONTEXT);
    }

    MGET(m, M_WAITOK, MT_DATA);
    if (message_buffer->length > MLEN)
        MCLGET(m, M_WAITOK);
    m_append(m, message_buffer->length, message_buffer->value);

    MGET(mic, M_WAITOK, MT_DATA);
    if (token_buffer->length > MLEN)
        MCLGET(mic, M_WAITOK);
    m_append(mic, token_buffer->length, token_buffer->value);

    maj_stat = KGSS_VERIFY_MIC(ctx, minor_status, m, mic, qop_state);

    m_freem(m);
    m_freem(mic);

    return (maj_stat);
}
开发者ID:cyrilmagsuci,项目名称:freebsd,代码行数:32,代码来源:gss_verify_mic.c


示例3: smb_mbuf_get

/*
 * smb_mbuf_get
 *
 * Allocate mbufs to hold the amount of data specified.
 * A pointer to the head of the mbuf list is returned.
 */
struct mbuf *
smb_mbuf_get(uchar_t *buf, int nbytes)
{
	struct mbuf *mhead = 0;
	struct mbuf *m = 0;
	int count;
	int offset = 0;

	while (nbytes) {
		count = (nbytes > MCLBYTES) ? MCLBYTES : nbytes;
		nbytes -= count;

		if (mhead == 0) {
			MGET(mhead, M_WAIT, MT_DATA);
			m = mhead;
		} else {
			MGET(m->m_next, M_WAIT, MT_DATA);
			m = m->m_next;
		}

		if (count > MLEN) {
			MCLGET(m, M_WAIT);
		}

		m->m_len = count;
		bcopy(buf + offset, m->m_data, count);
		offset += count;
	}
	return (mhead);
}
开发者ID:bahamas10,项目名称:openzfs,代码行数:36,代码来源:smb_mbuf_util.c


示例4: AmOption_Price_Andersen

// This function computes the prices of bermudan swaption corresponding to the exercise strategy defined by andersen_struct.
static double AmOption_Price_Andersen(AndersenStruct *andersen_struct)
{
  long NbrMCsimulation;
  int NbrExerciseDates, j, j_start, m;
  double andersen_param, discounted_payoff, mean_estim, numeraire_j, PriceBermSwp;

  Interpolate_AndersenParams(andersen_struct);

  j_start = andersen_struct->j_start;
  NbrExerciseDates = andersen_struct->NbrExerciseDates;
  NbrMCsimulation = andersen_struct->NbrMCsimulation;

  mean_estim=0.;
  for (m=0; m<NbrMCsimulation; m++)
    {
      j=j_start;
      do
        {
          discounted_payoff = MGET(andersen_struct->DiscountedPayoff, j, m);
          numeraire_j = MGET(andersen_struct->NumeraireValue, j, m);
          andersen_param = GET(andersen_struct->AndersenParams, j);
          j++;
        }
      while (discounted_payoff*numeraire_j <=andersen_param && j<NbrExerciseDates);

      mean_estim += discounted_payoff;
    }

  PriceBermSwp = mean_estim/(double)NbrMCsimulation;

  return PriceBermSwp;
}
开发者ID:jayhsieh,项目名称:premia-13,代码行数:33,代码来源:mc_andersen_bermudanswaption.c


示例5: kprintf

DMD     *getdmd(int drv)
{
        DMD *dm;

#if DBGFSDRIVE
        kprintf("getdmd(%i)\n", drv);
#endif

        if (!(drvtbl[drv] = dm = MGET(DMD)))
                return ( (DMD *) 0 );

        if (!(dm->m_dtl = MGET(DND)))
                goto fredm;

        if (!(dm->m_dtl->d_ofd = MGET(OFD)))
                goto fredtl;

        if (!(dm->m_fatofd = MGET(OFD)))
                goto freofd;

        return(dm);

freofd: xmfreblk (dm->m_dtl->d_ofd);
fredtl: xmfreblk (dm->m_dtl);
fredm:  xmfreblk (dm);

        return ( (DMD *) 0 );
}
开发者ID:ragnar76,项目名称:emutos,代码行数:28,代码来源:fsdrive.c


示例6: moments_normal

/*Moments of normal distribution*/
static int moments_normal(PnlVect *c, int m, double mu, double gamma2)
{
/* Input: PnlVect *c  is of dimension m, 
          mu=mean of normal distribution, 
          gamma2=variance of normal distribution.  
   The moments of the normal distribution with mean mu and variance gamma2 up to
   degree m are calculated and stored in c.
*/
  int i,j,n,index1;
  PnlMat *a;

  index1=(int)(m/2+1.);
  LET(c,0)=mu;
  
  a=pnl_mat_create_from_double(m,index1,0.);
  
  for(j=0;j<m;j++)
  {
    MLET(a,j,0)=1;
  }
  
  for(i=2;i<m+1;i++)
    {
   index1=(int)(i/2+1.); 
    for (n=2;n<=index1;n++)
    {
      MLET(a,i-1,n-1)=MGET(a,i-2,n-2)*(i-1-2*(n-1)+2)+MGET(a,i-2,n-1);
      LET(c,i-1)=GET(c,i-1)+MGET(a,i-1,n-1)*pow(mu, (double) i-2.*(double) n+2.)*pow(sqrt(gamma2), 2*(double)n-2.);
    }
    LET(c,i-1)=GET(c,i-1)+ pow (mu,(double)i);
  }  
  pnl_mat_free (&a);

  return 1.;
}
开发者ID:jayhsieh,项目名称:premia-13,代码行数:36,代码来源:mc_polynomial.c


示例7: mvn_sample

void mvn_sample(gsl_vector *mean_cand, gsl_matrix *var)
{
  /* Takes a mean vec, mean and var matrix, 
   * var and gives vector of MVN(mean,var) realisations, x 
   */
  int i, j;
  int dimen = var -> size1;
  double value;
  gsl_matrix *disp;
  gsl_vector *ran;
  gsl_matrix *fast_species;
  
  fast_species = gsl_matrix_alloc(2, 2);
  gsl_matrix_set_identity(fast_species);
  
  for(i=0;i<dimen; i++) {
    if(MGET(var, i, i) <0.00000000001) {
      MSET(var, i, i, 1.0);
      MSET(fast_species, i, i, 0.0);
    }
  }
  
  disp = gsl_matrix_alloc(2, 2);
  ran = gsl_vector_alloc(2);
  gsl_matrix_memcpy(disp, var);
  if(postive_definite == 1) {
    gsl_linalg_cholesky_decomp(disp);
    for(i=0;i<dimen;i++) {
      for (j=i+1;j<dimen;j++) {
        MSET(disp,i,j,0.0);
      }
    }
  }else{
    value = pow(MGET(disp, 0 ,0), 0.5);
    gsl_matrix_set_identity(disp);
    MSET(disp, 0,0, value);
    MSET(disp, 1,1, value);       
  }

  for (j=0;j<dimen;j++) {
    VSET(ran,j,gsl_ran_gaussian(r,1.0));
  }

  /*remove update from slow species*/
  gsl_matrix_mul_elements(disp, fast_species);
    
  /*Add noise to mean cand*/
  gsl_blas_dgemv(CblasNoTrans,1.0, disp, ran, 1.0, mean_cand);
  for(i=0; i<2; i++)  {
    if(VGET(mean_cand,i)<=0.0001 && MGET(fast_species, i, i) > 0.000001)
      VSET(mean_cand,i,0.0001);
  }
  gsl_vector_free(ran);
  gsl_matrix_free(disp);
  gsl_matrix_free(fast_species);
}
开发者ID:csgillespie,项目名称:hybrid-pmcmc,代码行数:56,代码来源:sde.c


示例8: move

void move(struct mat * ro, struct mat * RO_r, struct mat * RO_n, struct mat * r,
          struct mat * u, struct mat * n)
{
    double a = MGET(r, 2, 0);
    double dx = MGET(u, 0, 0) + MGET(n, 0, 0);
    double da = MGET(u, 1, 0) + MGET(n, 1, 0);

    double ao = a + da;

    //printf("ao = %f\n", ao);
    if (ao > M_PI)
    {
        ao = ao - 2.0 * M_PI;
    }
    if (ao < -M_PI)
    {
        ao = ao + 2.0 * M_PI;
    }

    struct mat * dp = mat(2, 1);

    MSET(dp, 0, 0, dx);
    //MSET(dp, 1, 0, da);

    struct mat * to = mat(2, 1);
    struct mat * TO_r = mat(2, 3);
    struct mat * TO_dt = mat(2, 2);

    from_frame(to, TO_r, TO_dt, r, dp);

    float AO_a = 1;
    float AO_da = 1;

    copy_into(RO_r, TO_r, 0, 0);
    MSET(RO_r, 2, 0, 0);
    MSET(RO_r, 2, 1, 0);
    MSET(RO_r, 2, 2, AO_a);

    copy_into(RO_n, TO_dt, 0, 0);
    MSET(RO_n, 0, 1, 0);
    MSET(RO_n, 1, 1, 0);
    MSET(RO_n, 2, 1, AO_da);

    //print_mat(to);
    //printf("%f\n", ao);

    copy_into(ro, to, 0, 0);
    MSET(ro, 2, 0, ao);

    free(to);
    free(TO_r);
    free(TO_dt);
    free(dp);
}
开发者ID:drhastings,项目名称:slam,代码行数:54,代码来源:move.c


示例9: reconfig

/*
 * Try to reconfigure the audio device to match the file encoding.
 * If this fails, we should attempt to make the input data match the
 * device encoding.  For now, we give up on this file.
 *
 * Returns TRUE if successful.  Returns FALSE if not.
 */
static int
reconfig(void)
{
	int	err;
	char	msg[AUDIO_MAX_ENCODE_INFO];

	Dev_hdr = File_hdr;
	err = audio_set_play_config(Audio_fd, &Dev_hdr);

	switch (err) {
	case AUDIO_SUCCESS:
		return (TRUE);

	case AUDIO_ERR_NOEFFECT:
		/*
		 * Couldn't change the device.
		 * Check to see if we're nearly compatible.
		 * audio_cmp_hdr() returns >0 if only sample rate difference.
		 */
		if (audio_cmp_hdr(&Dev_hdr, &File_hdr) > 0) {
			double	ratio;

			ratio = (double)abs((int)
			    (Dev_hdr.sample_rate - File_hdr.sample_rate)) /
			    (double)File_hdr.sample_rate;
			if (ratio <= SAMPLE_RATE_THRESHOLD) {
				if (Verbose) {
					Error(stderr,
					    MGET("%s: WARNING: %s sampled at "
					    "%d, playing at %d\n"),
					    prog, Ifile, File_hdr.sample_rate,
					    Dev_hdr.sample_rate);
				}
				return (TRUE);
			}
			Error(stderr,
			    MGET("%s: %s sample rate %d not available\n"),
			    prog, Ifile, File_hdr.sample_rate);
			return (FALSE);
		}
		(void) audio_enc_to_str(&File_hdr, msg);
		Error(stderr, MGET("%s: %s encoding not available: %s\n"),
		    prog, Ifile, msg);
		return (FALSE);

	default:
		Error(stderr,
		    MGET("%s: %s audio encoding type not available\n"),
		    prog, Ifile);
		exit(1);
	}
	return (TRUE);
}
开发者ID:0xffea,项目名称:illumos-gate,代码行数:60,代码来源:audioplay.c


示例10: initmux

/*
 * initmux()
 *
 * Description:
 *      Allocates memory for carrying out demultiplexing/multiplexing.
 *
 * Arguments:
 *      int		unitsz		Bytes per unit
 *	int		unitsp		Samples per unit
 *
 * Returns:
 *      void
 */
static void
initmux(int unitsz, int unitsp)
{
	int	c;		/* Channel */
	int	in_ch_size;	/* Input channel size */

	/* Size of each input channel */
	in_ch_size = insiz / File_hdr.channels;

	/* Size of each output channel */
	out_ch_size = in_ch_size * unitsp / unitsz;

	/* Allocate pointers to input channels */
	in_ch_data = malloc(sizeof (unsigned char *) * File_hdr.channels);

	if (in_ch_data == NULL) {
		Error(stderr, MGET("%s: couldn't allocate %dK buf\n"),
		    prog, sizeof (unsigned char *) * File_hdr.channels / 1000);
		exit(1);
	}

	/* Allocate input channels */
	for (c = 0; c < File_hdr.channels; c++) {
		in_ch_data[c] = malloc(sizeof (unsigned char) * in_ch_size);

		if (in_ch_data[c] == NULL) {
			Error(stderr, MGET("%s: couldn't allocate %dK buf\n"),
			    prog, in_ch_size / 1000);
			exit(1);
		}
	}

	/* Allocate pointers to output channels */
	out_ch_data = malloc(sizeof (unsigned char *) * File_hdr.channels);

	if (out_ch_data == NULL) {
		Error(stderr, MGET("%s: couldn't allocate %dK buf\n"),
		    prog, sizeof (unsigned char *) * File_hdr.channels / 1000);
		exit(1);
	}

	/* Allocate output channels */
	for (c = 0; c < File_hdr.channels; c++) {
		out_ch_data[c] = malloc(sizeof (unsigned char) * out_ch_size);

		if (out_ch_data[c] == NULL) {
			Error(stderr, MGET("%s: couldn't allocate %dK buf\n"),
			    prog, out_ch_size / 1000);
			exit(1);
		}
	}
}
开发者ID:0xffea,项目名称:illumos-gate,代码行数:65,代码来源:audioplay.c


示例11: K_getPhasedRVLine

double K_getPhasedRVLine(ok_kernel* k, int planet, int row, int column) {
    static gsl_matrix* phasedRVLine = NULL;
    if (planet >= 1) {
        if (k->ndata == 0)
            return -1;

        int np = K_getNplanets(k);
        double masses[np + 1];
        double periods[np + 1];
        for (int i = 1; i <= np; i++) {
            masses[i] = K_getElement(k, i, MASS);
            periods[i] = K_getElement(k, i, PER);
            if (i != planet) {
                K_setElement(k, i, MASS, 0.);
                K_setElement(k, i, PER, 10000.);
            }
        };

        double period = K_getElement(k, planet, PER);
        int samples = -row;
        if (phasedRVLine != NULL) {
            gsl_matrix_free(phasedRVLine);
            phasedRVLine = NULL;
        }
        double** comp = K_getCompiled(k);

        phasedRVLine = K_integrateStellarVelocity(k, comp[0][0],
                       comp[k->ndata - 1][0],
                       samples,
                       NULL, NULL);

        double mint = MGET(phasedRVLine, 0, T_TIME);
        for (int i = 0; i < MROWS(phasedRVLine); i++) {
            double t = fmod((MGET(phasedRVLine, i, 0) - mint), period);
            MSET(phasedRVLine, i, 0, t);
        }
        ok_sort_matrix(phasedRVLine, 0);

        for (int i = 1; i <= np; i++) {
            K_setElement(k, i, MASS, masses[i]);
            K_setElement(k, i, PER, periods[i]);
        }

        return 1;
    } else {
        return MGET(phasedRVLine, row, column);
    }
}
开发者ID:giordano,项目名称:Systemic2,代码行数:48,代码来源:javascript.c


示例12: smb_mbuf_allocate

/*
 * Allocate enough mbufs to accommodate the residual count in uio,
 * and setup the uio_iov to point to them.
 *
 * This is used by the various SMB read code paths.  That code is
 * going to do a disk read into this buffer, so we'd like it to be
 * large and contiguous.  Use an external (M_EXT) buffer.
 */
struct mbuf *
smb_mbuf_allocate(struct uio *uio)
{
	mbuf_t	*m = 0;
	int	len = uio->uio_resid;

	MGET(m, M_WAIT, MT_DATA);
	if (len > MCLBYTES) {
		/* Like MCLGET(), but bigger buf. */
		m->m_ext.ext_buf = kmem_zalloc(len, KM_SLEEP);
		m->m_data = m->m_ext.ext_buf;
		m->m_flags |= M_EXT;
		m->m_ext.ext_size = len;
		m->m_ext.ext_ref = smb_mbuf_kmem_ref;
	} else if (len > MLEN) {
		/* Use the kmem cache. */
		MCLGET(m, M_WAIT);
	}
	m->m_len = len;

	uio->uio_iov->iov_base = m->m_data;
	uio->uio_iov->iov_len = m->m_len;
	uio->uio_iovcnt = 1;

	return (m);
}
开发者ID:bahamas10,项目名称:openzfs,代码行数:34,代码来源:smb_mbuf_util.c


示例13: sbappendaddr_locked_internal

/* Helper routine that appends data, control, and address to a sockbuf. */
static int
sbappendaddr_locked_internal(struct sockbuf *sb, const struct sockaddr *asa,
    struct mbuf *m0, struct mbuf *control, struct mbuf *ctrl_last)
{
	struct mbuf *m, *n, *nlast;
#if MSIZE <= 256
	if (asa->sa_len > MLEN)
		return (0);
#endif
	MGET(m, M_DONTWAIT, MT_SONAME);
	if (m == 0)
		return (0);
	m->m_len = asa->sa_len;
	bcopy(asa, mtod(m, caddr_t), asa->sa_len);
	if (ctrl_last)
		ctrl_last->m_next = m0;	/* concatenate data to control */
	else
		control = m0;
	m->m_next = control;
	for (n = m; n->m_next != NULL; n = n->m_next)
		sballoc(sb, n);
	sballoc(sb, n);
	nlast = n;
	SBLINKRECORD(sb, m);

	sb->sb_mbtail = nlast;
	SBLASTMBUFCHK(sb);

	SBLASTRECORDCHK(sb);
	return (1);
}
开发者ID:dcui,项目名称:FreeBSD-9.3_kernel,代码行数:32,代码来源:uipc_sockbuf.c


示例14: igmp_init

void
igmp_init(void)
{
	struct ipoption *ra;

	/*
	 * To avoid byte-swapping the same value over and over again.
	 */
	igmp_all_hosts_group = htonl(INADDR_ALLHOSTS_GROUP);
	igmp_all_rtrs_group = htonl(INADDR_ALLRTRS_GROUP);

	igmp_timers_are_running = 0;

	/*
	 * Construct a Router Alert option to use in outgoing packets
	 */
	MGET(router_alert, M_DONTWAIT, MT_DATA);
	ra = mtod(router_alert, struct ipoption *);
	ra->ipopt_dst.s_addr = 0;
	ra->ipopt_list[0] = IPOPT_RA;	/* Router Alert Option */
	ra->ipopt_list[1] = 0x04;	/* 4 bytes long */
	ra->ipopt_list[2] = 0x00;
	ra->ipopt_list[3] = 0x00;
	router_alert->m_len = sizeof(ra->ipopt_dst) + ra->ipopt_list[1];

	Head = (struct router_info *) 0;
}
开发者ID:AoLaD,项目名称:rtems,代码行数:27,代码来源:igmp.c


示例15: usage

static void
usage(void)
{
	Error(stderr, MGET("Record an audio file -- usage:\n"
	    "\t%s [-af] [-v vol]\n"
	    "\t%.*s [-c channels] [-s rate] [-e encoding]\n"
	    "\t%.*s [-t time] [-i info] [-d dev] [-T au|wav|aif[f]] [file]\n"
	    "where:\n"
	    "\t-a\tAppend to output file\n"
	    "\t-f\tIgnore sample rate differences on append\n"
	    "\t-v\tSet record volume (0 - %d)\n"
	    "\t-c\tSpecify number of channels to record\n"
	    "\t-s\tSpecify rate in samples per second\n"
	    "\t-e\tSpecify encoding (ulaw | alaw | [u]linear | linear8 )\n"
	    "\t-t\tSpecify record time (hh:mm:ss.dd)\n"
	    "\t-i\tSpecify a file header information string\n"
	    "\t-d\tSpecify audio device (default: /dev/audio)\n"
	    "\t-T\tSpecify the audio file type (default: au)\n"
	    "\tfile\tRecord to named file\n"
	    "\t\tIf no file specified, write to stdout\n"
	    "\t\tDefault audio encoding is ulaw, 8khz, mono\n"
	    "\t\tIf -t is not specified, record until ^C\n"),
	    prog,
	    strlen(prog), "                    ",
	    strlen(prog), "                    ",
	    MAX_GAIN);
	exit(1);
}
开发者ID:0xffea,项目名称:illumos-gate,代码行数:28,代码来源:audiorecord.c


示例16: m_split

/*
 * Partition an mbuf chain in two pieces, returning the tail --
 * all but the first len0 bytes.  In case of failure, it returns NULL and
 * attempts to restore the chain to its original state.
 */
struct mbuf *
m_split(struct mbuf *m0, int len0, int wait)
{
	struct mbuf *m, *n;
	unsigned len = len0, remain, olen;

	for (m = m0; m && len > m->m_len; m = m->m_next)
		len -= m->m_len;
	if (m == NULL)
		return (NULL);
	remain = m->m_len - len;
	if (m0->m_flags & M_PKTHDR) {
		MGETHDR(n, wait, m0->m_type);
		if (n == NULL)
			return (NULL);
		if (m_dup_pkthdr(n, m0, wait)) {
			m_freem(n);
			return (NULL);
		}
		n->m_pkthdr.len -= len0;
		olen = m0->m_pkthdr.len;
		m0->m_pkthdr.len = len0;
		if (m->m_flags & M_EXT)
			goto extpacket;
		if (remain > MHLEN) {
			/* m can't be the lead packet */
			MH_ALIGN(n, 0);
			n->m_next = m_split(m, len, wait);
			if (n->m_next == NULL) {
				(void) m_free(n);
				m0->m_pkthdr.len = olen;
				return (NULL);
			} else
				return (n);
		} else
			MH_ALIGN(n, remain);
	} else if (remain == 0) {
		n = m->m_next;
		m->m_next = NULL;
		return (n);
	} else {
		MGET(n, wait, m->m_type);
		if (n == NULL)
			return (NULL);
		M_ALIGN(n, remain);
	}
extpacket:
	if (m->m_flags & M_EXT) {
		n->m_ext = m->m_ext;
		MCLADDREFERENCE(m, n);
		n->m_data = m->m_data + len;
	} else {
		memcpy(mtod(n, caddr_t), mtod(m, caddr_t) + len, remain);
	}
	n->m_len = remain;
	m->m_len = len;
	n->m_next = m->m_next;
	m->m_next = NULL;
	return (n);
}
开发者ID:orumin,项目名称:openbsd-efivars,代码行数:65,代码来源:uipc_mbuf.c


示例17: nfs_rephead

/*
 * Generate the rpc reply header
 * siz arg. is used to decide if adding a cluster is worthwhile
 */
struct mbuf *
nfs_rephead(int siz, struct nfsrv_descript *nd, int err,
    struct mbuf **mbp, caddr_t *bposp)
{
	u_int32_t *tl;
	struct mbuf *mreq;
	caddr_t bpos;
	struct mbuf *mb;

	if (err == EBADRPC)
		return (NULL);

	nd->nd_repstat = err;
	if (err && (nd->nd_flag & ND_NFSV3) == 0)	/* XXX recheck */
		siz = 0;

	MGET(mreq, M_WAITOK, MT_DATA);

	/*
	 * If this is a big reply, use a cluster
	 */
	mreq->m_len = 0;
	if (siz >= MINCLSIZE) {
		MCLGET(mreq, M_WAITOK);
	}
	mb = mreq;
	bpos = mtod(mb, caddr_t);

	if (err != NFSERR_RETVOID) {
		tl = nfsm_build(u_int32_t *, NFSX_UNSIGNED);
		if (err)
			*tl = txdr_unsigned(nfsrv_errmap(nd, err));
		else
			*tl = 0;
	}
开发者ID:ChaosJohn,项目名称:freebsd,代码行数:39,代码来源:nfs_srvkrpc.c


示例18: gss_get_mic

OM_uint32
gss_get_mic(OM_uint32 *minor_status,
    const gss_ctx_id_t ctx,
    gss_qop_t qop_req,
    const gss_buffer_t message_buffer,
    gss_buffer_t message_token)
{
	OM_uint32 maj_stat;
	struct mbuf *m, *mic;

	if (!ctx) {
		*minor_status = 0;
		return (GSS_S_NO_CONTEXT);
	}

	MGET(m, M_WAITOK, MT_DATA);
	if (message_buffer->length > MLEN)
		MCLGET(m, M_WAITOK);
	m_append(m, message_buffer->length, message_buffer->value);

	maj_stat = KGSS_GET_MIC(ctx, minor_status, qop_req, m, &mic);

	m_freem(m);
	if (maj_stat == GSS_S_COMPLETE) {
		message_token->length = m_length(mic, NULL);
		message_token->value = malloc(message_token->length,
		    M_GSSAPI, M_WAITOK);
		m_copydata(mic, 0, message_token->length,
		    message_token->value);
		m_freem(mic);
	}

	return (maj_stat);
}
开发者ID:2asoft,项目名称:freebsd,代码行数:34,代码来源:gss_get_mic.c


示例19: xdrmbuf_getall

struct mbuf *
xdrmbuf_getall(XDR *xdrs)
{
	struct mbuf *m0, *m;

	KASSERT(xdrs->x_ops == &xdrmbuf_ops && xdrs->x_op == XDR_DECODE,
	    ("xdrmbuf_append: invalid XDR stream"));

	m0 = (struct mbuf *) xdrs->x_base;
	m = (struct mbuf *) xdrs->x_private;
	if (m0 != m) {
		while (m0->m_next != m)
			m0 = m0->m_next;
		m0->m_next = NULL;
		xdrs->x_private = NULL;
	} else {
		xdrs->x_base = NULL;
		xdrs->x_private = NULL;
	}

	if (m)
		m_adj(m, xdrs->x_handy);
	else
		MGET(m, M_WAITOK, MT_DATA);
	return (m);
}
开发者ID:edgar-pek,项目名称:PerspicuOS,代码行数:26,代码来源:xdr_mbuf.c


示例20: m_prepend

/*
 * Ensure len bytes of contiguous space at the beginning of the mbuf chain
 */
struct mbuf *
m_prepend(struct mbuf *m, int len, int how)
{
	struct mbuf *mn;

	if (len > MHLEN)
		panic("mbuf prepend length too big");

	if (M_LEADINGSPACE(m) >= len) {
		m->m_data -= len;
		m->m_len += len;
	} else {
		MGET(mn, how, m->m_type);
		if (mn == NULL) {
			m_freem(m);
			return (NULL);
		}
		if (m->m_flags & M_PKTHDR)
			M_MOVE_PKTHDR(mn, m);
		mn->m_next = m;
		m = mn;
		MH_ALIGN(m, len);
		m->m_len = len;
	}
	if (m->m_flags & M_PKTHDR)
		m->m_pkthdr.len += len;
	return (m);
}
开发者ID:orumin,项目名称:openbsd-efivars,代码行数:31,代码来源:uipc_mbuf.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ MGETHDR函数代码示例发布时间:2022-05-30
下一篇:
C++ MGA_CONTEXT函数代码示例发布时间: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