您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ ALLOC函数代码示例

51自学网 2021-06-01 19:34:39
  C++
这篇教程C++ ALLOC函数代码示例写得很实用,希望能帮到您。

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

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

示例1: pathname

//.........这里部分代码省略.........    fill_fopen_filefunc(&us.z_filefunc);  }  else  {    us.z_filefunc =  *pzlib_filefunc_def;  }  us.filestream = (*(us.z_filefunc.zopen_file))(us.z_filefunc.opaque, path, ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_EXISTING);  if (us.filestream == NULL)  {    return NULL;  }  central_pos = unzlocal_SearchCentralDir(&us.z_filefunc, us.filestream);  if (central_pos == 0)  {    err = UNZ_ERRNO;  }  if (ZSEEK(us.z_filefunc, us.filestream, central_pos, SEEK_SET) != 0)  {    err = UNZ_ERRNO;  }  /* the signature, already checked */  if (unzlocal_getLong(&us.z_filefunc, us.filestream, &uL) != UNZ_OK)  {    err = UNZ_ERRNO;  }  /* number of this disk */  if (unzlocal_getShort(&us.z_filefunc, us.filestream, &number_disk) != UNZ_OK)  {    err = UNZ_ERRNO;  }  /* number of the disk with the start of the central directory */  if (unzlocal_getShort(&us.z_filefunc, us.filestream, &number_disk_with_CD) != UNZ_OK)  {    err = UNZ_ERRNO;  }  /* total number of entries in the central dir on this disk */  if (unzlocal_getShort(&us.z_filefunc, us.filestream, &us.gi.number_entry) != UNZ_OK)  {    err = UNZ_ERRNO;  }  /* total number of entries in the central dir */  if (unzlocal_getShort(&us.z_filefunc, us.filestream, &number_entry_CD) != UNZ_OK)  {    err = UNZ_ERRNO;  }  if ((number_entry_CD != us.gi.number_entry) || (number_disk_with_CD != 0) || (number_disk != 0))  {    err = UNZ_BADZIPFILE;  }  /* size of the central directory */  if (unzlocal_getLong(&us.z_filefunc, us.filestream, &us.size_central_dir) != UNZ_OK)  {    err = UNZ_ERRNO;  }  /* offset of start of central directory with respect to the  starting disk number */  if (unzlocal_getLong(&us.z_filefunc, us.filestream, &us.offset_central_dir) != UNZ_OK)  {    err = UNZ_ERRNO;  }  /* zipfile comment length */  if (unzlocal_getShort(&us.z_filefunc, us.filestream, &us.gi.size_comment) != UNZ_OK)  {    err = UNZ_ERRNO;  }  if ((central_pos < us.offset_central_dir + us.size_central_dir) && (err == UNZ_OK))  {    err = UNZ_BADZIPFILE;  }  if (err != UNZ_OK)  {    ZCLOSE(us.z_filefunc, us.filestream);    return NULL;  }  us.byte_before_the_zipfile = central_pos - (us.offset_central_dir + us.size_central_dir);  us.central_pos = central_pos;  us.pfile_in_zip_read = NULL;  us.encrypted = 0;  s = (unz_s*)ALLOC(sizeof(unz_s));  *s = us;  unzGoToFirstFile((unzFile)s);  return (unzFile)s;}
开发者ID:Doodle-Jump,项目名称:PC,代码行数:101,


示例2: opus_decode_frame

static int opus_decode_frame(OpusDecoder *st, const unsigned char *data,      int len, opus_val16 *pcm, int frame_size, int decode_fec){   void *silk_dec;   CELTDecoder *celt_dec;   int i, silk_ret=0, celt_ret=0;   ec_dec dec;   opus_int32 silk_frame_size;   VARDECL(opus_int16, pcm_silk);   VARDECL(opus_val16, pcm_transition);   VARDECL(opus_val16, redundant_audio);   int audiosize;   int mode;   int transition=0;   int start_band;   int redundancy=0;   int redundancy_bytes = 0;   int celt_to_silk=0;   int c;   int F2_5, F5, F10, F20;   const opus_val16 *window;   opus_uint32 redundant_rng = 0;   ALLOC_STACK;   silk_dec = (char*)st+st->silk_dec_offset;   celt_dec = (CELTDecoder*)((char*)st+st->celt_dec_offset);   F20 = st->Fs/50;   F10 = F20>>1;   F5 = F10>>1;   F2_5 = F5>>1;   if (frame_size < F2_5)      return OPUS_BUFFER_TOO_SMALL;   /* Payloads of 1 (2 including ToC) or 0 trigger the PLC/DTX */   if (len<=1)   {      data = NULL;      /* In that case, don't conceal more than what the ToC says */      frame_size = IMIN(frame_size, st->frame_size);   }   if (data != NULL)   {      audiosize = st->frame_size;      mode = st->mode;      ec_dec_init(&dec,(unsigned char*)data,len);   } else {      audiosize = frame_size;      if (st->prev_mode == 0)      {         /* If we haven't got any packet yet, all we can do is return zeros */         for (i=0;i<audiosize*st->channels;i++)            pcm[i] = 0;         RESTORE_STACK;         return audiosize;      } else {         mode = st->prev_mode;      }   }   /* For CELT/hybrid PLC of more than 20 ms, do multiple calls */   if (data==NULL && frame_size > F20 && mode != MODE_SILK_ONLY)   {      int nb_samples = 0;      do {         int ret = opus_decode_frame(st, NULL, 0, pcm, F20, 0);         if (ret != F20)            return OPUS_INTERNAL_ERROR;         pcm += F20*st->channels;         nb_samples += F20;      } while (nb_samples < frame_size);      RESTORE_STACK;      return frame_size;   }   ALLOC(pcm_transition, F5*st->channels, opus_val16);   if (data!=NULL && st->prev_mode > 0 && (       (mode == MODE_CELT_ONLY && st->prev_mode != MODE_CELT_ONLY && !st->prev_redundancy)    || (mode != MODE_CELT_ONLY && st->prev_mode == MODE_CELT_ONLY) )      )   {      transition = 1;      if (mode == MODE_CELT_ONLY)         opus_decode_frame(st, NULL, 0, pcm_transition, IMIN(F5, audiosize), 0);   }   if (audiosize > frame_size)   {      /*fprintf(stderr, "PCM buffer too small: %d vs %d (mode = %d)/n", audiosize, frame_size, mode);*/      RESTORE_STACK;      return OPUS_BAD_ARG;   } else {      frame_size = audiosize;   }   ALLOC(pcm_silk, IMAX(F10, frame_size)*st->channels, opus_int16);   ALLOC(redundant_audio, F5*st->channels, opus_val16);   /* SILK processing */   if (mode != MODE_CELT_ONLY)   {//.........这里部分代码省略.........
开发者ID:AshishNamdev,项目名称:mozilla-central,代码行数:101,


示例3: ra_sound_allocate

static VALUE ra_sound_allocate(VALUE klass) {    RA_SOUND *snd = ALLOC(RA_SOUND);    memset(snd, 0, sizeof(RA_SOUND));    VALUE self = Data_Wrap_Struct(klass, ra_sound_mark, ra_sound_free, snd);    return self;}
开发者ID:adamggg,项目名称:ruby-audio,代码行数:6,


示例4: cuddSymmSifting

/**  @brief Symmetric sifting algorithm.  @details Assumes that no dead nodes are present.    <ol>    <li> Order all the variables according to the number of entries in    each unique subtable.    <li> Sift the variable up and down, remembering each time the total    size of the DD heap and grouping variables that are symmetric.    <li> Select the best permutation.    <li> Repeat 3 and 4 for all variables.    </ol>  @return 1 plus the number of symmetric variables if successful; 0  otherwise.  @sideeffect None  @see cuddSymmSiftingConv*/intcuddSymmSifting(  DdManager * table,  int  lower,  int  upper){    int		i;    IndexKey	*var;    int		size;    int		x;    int		result;    int		symvars;    int		symgroups;#ifdef DD_STATS    int		previousSize;#endif    size = table->size;    /* Find order in which to sift variables. */    var = ALLOC(IndexKey,size);    if (var == NULL) {	table->errorCode = CUDD_MEMORY_OUT;	goto ddSymmSiftingOutOfMem;    }    for (i = 0; i < size; i++) {	x = table->perm[i];	var[i].index = i;	var[i].keys = table->subtables[x].keys;    }    util_qsort(var,size,sizeof(IndexKey),ddSymmUniqueCompare);    /* Initialize the symmetry of each subtable to itself. */    for (i = lower; i <= upper; i++) {	table->subtables[i].next = i;    }    for (i = 0; i < ddMin(table->siftMaxVar,size); i++) {	if (table->ddTotalNumberSwapping >= table->siftMaxSwap)	    break;        if (util_cpu_time() - table->startTime > table->timeLimit) {            table->autoDyn = 0; /* prevent further reordering */            break;        }        if (table->terminationCallback != NULL &&            table->terminationCallback(table->tcbArg)) {            table->autoDyn = 0; /* prevent further reordering */            break;        }	x = table->perm[var[i].index];#ifdef DD_STATS	previousSize = (int) (table->keys - table->isolated);#endif	if (x < lower || x > upper) continue;	if (table->subtables[x].next == (unsigned) x) {	    result = ddSymmSiftingAux(table,x,lower,upper);	    if (!result) goto ddSymmSiftingOutOfMem;#ifdef DD_STATS	    if (table->keys < (unsigned) previousSize + table->isolated) {		(void) fprintf(table->out,"-");	    } else if (table->keys > (unsigned) previousSize +		       table->isolated) {		(void) fprintf(table->out,"+"); /* should never happen */	    } else {		(void) fprintf(table->out,"=");	    }	    fflush(table->out);#endif	}    }    FREE(var);    ddSymmSummary(table, lower, upper, &symvars, &symgroups);#ifdef DD_STATS    (void) fprintf(table->out, "/n#:S_SIFTING %8d: symmetric variables/n",//.........这里部分代码省略.........
开发者ID:VerifiableRobotics,项目名称:slugs,代码行数:101,


示例5: rev_branch_merge

/* * Merge a set of per-file branches into a global branch */static voidrev_branch_merge (rev_ref **branches, int nbranch,		  rev_ref *branch, rev_list *rl){	int nlive;	int n;	rev_commit *prev = NULL;	rev_commit *head = NULL, **tail = &head;	rev_commit **commits;	rev_commit *commit;	rev_commit *latest;	rev_commit **p;	int lazy = 0;	time_t start = 0;	ALLOC((commits = calloc (nbranch, sizeof (rev_commit *))), "rev_branch_merge");	nlive = 0;//	printf("rev_branch_merge: nbranch=%d/n", nbranch);		for (n = 0; n < nbranch; n++) {		rev_commit *c;		/*		 * Initialize commits to head of each branch		 */		c = commits[n] = branches[n]->commit;		/*		* Compute number of branches with remaining entries		*/		if (!c)			continue;		if (branches[n]->tail) {			c->tailed = 1;			continue;		}		nlive++;		while (c && !c->tail) {			if (!start || time_compare(c->date, start) < 0)			    {//				printf("  1:setting start=%ld:%s (from %s)/n", start, ctime_nonl(&start), c->file->name);				start = c->date;			    }			c = c->parent;		}		if (c && (c->file || c->date != c->parent->date)) {			if (!start || time_compare(c->date, start) < 0) {//				printf("  2:setting start=%ld:%s (from %s)/n", start, ctime_nonl(&start), c->file->name);				start = c->date;			}		}	}	for (n = 0; n < nbranch; n++) {		rev_commit *c = commits[n];#if 0		printf("Doing commit %p: @ %ld/n", c, c->date);		if (c->file) printf("  %s/n", c->file->name);#endif				if (!c->tailed)			continue;		if (!start || time_compare(start, c->date) >= 0)			continue;		if (c->file) {		    /*		      This case can occur if files have been added to		      a branch since it's creation.		    */			printf(	"Warning: %s too late date %s through branch %s (%ld:%ld=%ld)/n",				c->file->name, ctime_nonl(&c->date), branch->name, start, c->date, start-c->date);			continue;		}		commits[n] = NULL;	}	/*	 * Walk down branches until each one has merged with the	 * parent branch	 */	while (nlive > 0 && nbranch > 0) {		for (n = 0, p = commits, latest = NULL; n < nbranch; n++) {			rev_commit *c = commits[n];			if (!c)				continue;			*p++ = c;			if (c->tailed)				continue;			if (!latest || time_compare(latest->date, c->date) < 0)				latest = c;		}		nbranch = p - commits;		/*		 * Construct current commit		 */		if (!lazy) {			commit = rev_commit_build (commits, latest, nbranch);//.........这里部分代码省略.........
开发者ID:eatnumber1,项目名称:parsecvs,代码行数:101,


示例6: s_to_rp2

/*** The routine above returns the sizes of the objects, and saves the lists**   (the list heads are static).  S then calls again with appropriately**   sized arrays to this routine. This stuffs the arrays and frees the memory*/void s_to_rp2(Sint *n,         Sint *nsplit,    Sint *nnode,     Sint *ncat,           Sint *numcat,    Sint *maxcat,    Sint *xvals,     Sint *which,           double *cptable, double *dsplit,  Sint *isplit,    Sint *csplit,          double *dnode,   Sint *inode)    {    int i;    int  nodenum, j;    struct cptable *cp, *cp2;    double **ddnode  , *ddsplit[3];    Sint   *iinode[6], *iisplit[3];    Sint   **ccsplit;    double scale;     /*    ** create the "ragged array" pointers to the matrices    */    ddnode = (double **) ALLOC(3+rp.num_resp, sizeof(double *));    for (i=0; i<(3+rp.num_resp); i++) {    ddnode[i] = dnode;  dnode  += *nnode;    }    for (i=0; i<3; i++) {    ddsplit[i]= dsplit; dsplit += *nsplit;    }    for (i=0; i<6; i++) {    iinode[i] = inode;  inode  += *nnode;    }    for (i=0; i<3; i++) {    iisplit[i]= isplit; isplit += *nsplit;    }    /* I don't understand this next line.  Even if I don't need ccsplit    ** (maxcat=0), not allocating it makes S memory fault.  Not that    **  4 extra bytes is any big deal....    */    if (*maxcat==0) i=1; else i = *maxcat;    ccsplit = (Sint **)CALLOC(i, sizeof(Sint *));    for (i=0; i<*maxcat; i++) {    ccsplit[i] = csplit;   csplit += *ncat;    }    /* retrieve the complexity table */    scale = 1/tree->risk;    i=0;    for (cp = &cptab; cp !=0; cp= cp->forward) {    cptable[i++] = cp->cp * scale;    cptable[i++] = cp->nsplit;    cptable[i++] = cp->risk * scale;    if (*xvals >1) {        cptable[i++] = cp->xrisk*scale;        cptable[i++] = cp->xstd *scale;        }    }    /* Now get the tree */    *nnode=0; *nsplit=0; *ncat=0;   /*array starting points */    rpmatrix(tree, nnode, nsplit, ncat, numcat,            ddsplit, iisplit, ccsplit, ddnode, iinode, 1);    /*    ** Now fix up the 'which' array    **   It would be a simple S match(), except that nodes sometimes get cut    */    for (i=0; i<*n; i++) {    nodenum = savewhich[i];    do {        for (j=0; j< *nnode; j++)        if (iinode[0][j] == nodenum) {            which[i] = j+1;            break;            }        nodenum /=2;        }  while (j >= *nnode);    }    /*    ** restore the memory    **  since the root was not calloced, I have to not free it (second arg    **  of free_tree).    */    free_tree(tree, 0);    for (cp=cptab.forward; cp!=0; ) {    cp2 = cp->forward;    Free(cp);    cp = cp2;    }    Free(ccsplit);    Free(savewhich);    }
开发者ID:xiangdiuxiu,项目名称:CodeShop,代码行数:94,


示例7: VRETURN

IZ_BOOL DxtEncoder::init(    izanagi::IMemoryAllocator* allocator,    izanagi::graph::CGraphicsDevice* device,    IZ_UINT width, IZ_UINT height,    const char* vtxShader,    const char* dxtShader,    const char* pixelShader){    m_width = width;    m_height = height;    char* buf = nullptr;    IZ_UINT allocatedSize = 0;    {        izanagi::CFileInputStream in;        VRETURN(in.Open(dxtShader));        allocatedSize = in.GetSize();        buf = (char*)ALLOC(allocator, allocatedSize);        in.Read(buf, 0, allocatedSize);        buf[allocatedSize] = 0;        m_dxt = device->CreatePixelShader(buf);        VRETURN(m_dxt);    }    {        izanagi::CFileInputStream in;        VRETURN(in.Open(vtxShader));        auto size = in.GetSize();        IZ_ASSERT(allocatedSize >= size);        in.Read(buf, 0, size);        buf[size] = 0;        m_vs = device->CreateVertexShader(buf);        VRETURN(m_vs);    }    {        izanagi::CFileInputStream in;        VRETURN(in.Open(pixelShader));        auto size = in.GetSize();        IZ_ASSERT(allocatedSize >= size);        in.Read(buf, 0, size);        buf[size] = 0;        m_ps = device->CreatePixelShader(buf);        VRETURN(m_ps);    }    FREE(allocator, buf);    {        m_shd = device->CreateShaderProgram();        VRETURN(m_shd);        VRETURN(m_shd->AttachVertexShader(m_vs));        VRETURN(m_shd->AttachPixelShader(m_dxt));    }    {        m_shdDraw = device->CreateShaderProgram();        VRETURN(m_shdDraw);        VRETURN(m_shdDraw->AttachVertexShader(m_vs));        VRETURN(m_shdDraw->AttachPixelShader(m_ps));    }    {        // NOTE        // DXTは 4x4 ブロックで、128bit/block.        // GL_RGBA32UI は 128bit/texel.        // すると、1texel が DXTのブロックのサイズと同じになるので、fragment shaderの1pixel出力がそのままDXTの1ブロックになる.        m_tex = device->CreateTexture(            width / 4, height / 4,            1,            izanagi::graph::E_GRAPH_PIXEL_FMT_RGBA32UI,            izanagi::graph::E_GRAPH_RSC_USAGE_STATIC);        VRETURN(m_tex);        CALL_GL_API(glGenFramebuffers(1, &m_fbo));        glGenBuffers(1, &m_pbo);        glBindBuffer(GL_PIXEL_PACK_BUFFER, m_pbo);        glBufferData(GL_PIXEL_PACK_BUFFER, width * height, 0, GL_STREAM_COPY);        glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);        m_texDxt = device->CreateTexture(            width, height,            1,            izanagi::graph::E_GRAPH_PIXEL_FMT_DXT5,            izanagi::graph::E_GRAPH_RSC_USAGE_STATIC);        VRETURN(m_tex);    }//.........这里部分代码省略.........
开发者ID:nakdai,项目名称:trials,代码行数:101,


示例8: silk_PLC_conceal

static inline void silk_PLC_conceal(    silk_decoder_state                  *psDec,             /* I/O Decoder state        */    silk_decoder_control                *psDecCtrl,         /* I/O Decoder control      */    opus_int16                          frame[]             /* O LPC residual signal    */){    opus_int   i, j, k;    opus_int   lag, idx, sLTP_buf_idx, shift1, shift2;    opus_int32 rand_seed, harm_Gain_Q15, rand_Gain_Q15, inv_gain_Q30;    opus_int32 energy1, energy2, *rand_ptr, *pred_lag_ptr;    opus_int32 LPC_pred_Q10, LTP_pred_Q12;    opus_int16 rand_scale_Q14;    opus_int16 *B_Q14, *exc_buf_ptr;    opus_int32 *sLPC_Q14_ptr;    VARDECL( opus_int16, exc_buf );    opus_int16 A_Q12[ MAX_LPC_ORDER ];    VARDECL( opus_int16, sLTP );    VARDECL( opus_int32, sLTP_Q14 );    silk_PLC_struct *psPLC = &psDec->sPLC;    opus_int32 prevGain_Q10[2];    SAVE_STACK;    ALLOC( exc_buf, 2*psPLC->subfr_length, opus_int16 );    ALLOC( sLTP, psDec->ltp_mem_length, opus_int16 );    ALLOC( sLTP_Q14, psDec->ltp_mem_length + psDec->frame_length, opus_int32 );    prevGain_Q10[0] = silk_RSHIFT( psPLC->prevGain_Q16[ 0 ], 6);    prevGain_Q10[1] = silk_RSHIFT( psPLC->prevGain_Q16[ 1 ], 6);    if( psDec->first_frame_after_reset ) {       silk_memset( psPLC->prevLPC_Q12, 0, sizeof( psPLC->prevLPC_Q12 ) );    }    /* Find random noise component */    /* Scale previous excitation signal */    exc_buf_ptr = exc_buf;    for( k = 0; k < 2; k++ ) {        for( i = 0; i < psPLC->subfr_length; i++ ) {            exc_buf_ptr[ i ] = (opus_int16)silk_SAT16( silk_RSHIFT(                silk_SMULWW( psDec->exc_Q14[ i + ( k + psPLC->nb_subfr - 2 ) * psPLC->subfr_length ], prevGain_Q10[ k ] ), 8 ) );        }        exc_buf_ptr += psPLC->subfr_length;    }    /* Find the subframe with lowest energy of the last two and use that as random noise generator */    silk_sum_sqr_shift( &energy1, &shift1, exc_buf,                         psPLC->subfr_length );    silk_sum_sqr_shift( &energy2, &shift2, &exc_buf[ psPLC->subfr_length ], psPLC->subfr_length );    if( silk_RSHIFT( energy1, shift2 ) < silk_RSHIFT( energy2, shift1 ) ) {        /* First sub-frame has lowest energy */        rand_ptr = &psDec->exc_Q14[ silk_max_int( 0, ( psPLC->nb_subfr - 1 ) * psPLC->subfr_length - RAND_BUF_SIZE ) ];    } else {        /* Second sub-frame has lowest energy */        rand_ptr = &psDec->exc_Q14[ silk_max_int( 0, psPLC->nb_subfr * psPLC->subfr_length - RAND_BUF_SIZE ) ];    }    /* Set up Gain to random noise component */    B_Q14          = psPLC->LTPCoef_Q14;    rand_scale_Q14 = psPLC->randScale_Q14;    /* Set up attenuation gains */    harm_Gain_Q15 = HARM_ATT_Q15[ silk_min_int( NB_ATT - 1, psDec->lossCnt ) ];    if( psDec->prevSignalType == TYPE_VOICED ) {        rand_Gain_Q15 = PLC_RAND_ATTENUATE_V_Q15[  silk_min_int( NB_ATT - 1, psDec->lossCnt ) ];    } else {        rand_Gain_Q15 = PLC_RAND_ATTENUATE_UV_Q15[ silk_min_int( NB_ATT - 1, psDec->lossCnt ) ];    }    /* LPC concealment. Apply BWE to previous LPC */    silk_bwexpander( psPLC->prevLPC_Q12, psDec->LPC_order, SILK_FIX_CONST( BWE_COEF, 16 ) );    /* Preload LPC coeficients to array on stack. Gives small performance gain */    silk_memcpy( A_Q12, psPLC->prevLPC_Q12, psDec->LPC_order * sizeof( opus_int16 ) );    /* First Lost frame */    if( psDec->lossCnt == 0 ) {        rand_scale_Q14 = 1 << 14;        /* Reduce random noise Gain for voiced frames */        if( psDec->prevSignalType == TYPE_VOICED ) {            for( i = 0; i < LTP_ORDER; i++ ) {                rand_scale_Q14 -= B_Q14[ i ];            }            rand_scale_Q14 = silk_max_16( 3277, rand_scale_Q14 ); /* 0.2 */            rand_scale_Q14 = (opus_int16)silk_RSHIFT( silk_SMULBB( rand_scale_Q14, psPLC->prevLTP_scale_Q14 ), 14 );        } else {            /* Reduce random noise for unvoiced frames with high LPC gain */            opus_int32 invGain_Q30, down_scale_Q30;            invGain_Q30 = silk_LPC_inverse_pred_gain( psPLC->prevLPC_Q12, psDec->LPC_order );            down_scale_Q30 = silk_min_32( silk_RSHIFT( (opus_int32)1 << 30, LOG2_INV_LPC_GAIN_HIGH_THRES ), invGain_Q30 );            down_scale_Q30 = silk_max_32( silk_RSHIFT( (opus_int32)1 << 30, LOG2_INV_LPC_GAIN_LOW_THRES ), down_scale_Q30 );            down_scale_Q30 = silk_LSHIFT( down_scale_Q30, LOG2_INV_LPC_GAIN_HIGH_THRES );            rand_Gain_Q15 = silk_RSHIFT( silk_SMULWB( down_scale_Q30, rand_Gain_Q15 ), 14 );        }    }    rand_seed    = psPLC->rand_seed;    lag          = silk_RSHIFT_ROUND( psPLC->pitchL_Q8, 8 );//.........这里部分代码省略.........
开发者ID:sherief,项目名称:opus,代码行数:101,


示例9: authdes_pk_seccreate

/* * Slightly modified version of authdessec_create which takes the public key * of the server principal as an argument. This spares us a call to * getpublickey() which in the nameserver context can cause a deadlock. */AUTH *authdes_pk_seccreate(const char *servername, netobj *pkey, u_int window,	const char *timehost, const des_block *ckey, nis_server *srvr){	AUTH *auth;	struct ad_private *ad;	char namebuf[MAXNETNAMELEN+1];	/*	 * Allocate everything now	 */	auth = ALLOC(AUTH);	if (auth == NULL) {		syslog(LOG_ERR, "authdes_pk_seccreate: out of memory");		return (NULL);	}	ad = ALLOC(struct ad_private);	if (ad == NULL) {		syslog(LOG_ERR, "authdes_pk_seccreate: out of memory");		goto failed;	}	ad->ad_fullname = ad->ad_servername = NULL; /* Sanity reasons */	ad->ad_timehost = NULL;	ad->ad_netid = NULL;	ad->ad_uaddr = NULL;	ad->ad_nis_srvr = NULL;	ad->ad_timediff.tv_sec = 0;	ad->ad_timediff.tv_usec = 0;	memcpy(ad->ad_pkey, pkey->n_bytes, pkey->n_len);	if (!getnetname(namebuf))		goto failed;	ad->ad_fullnamelen = RNDUP((u_int) strlen(namebuf));	ad->ad_fullname = (char *)mem_alloc(ad->ad_fullnamelen + 1);	ad->ad_servernamelen = strlen(servername);	ad->ad_servername = (char *)mem_alloc(ad->ad_servernamelen + 1);	if (ad->ad_fullname == NULL || ad->ad_servername == NULL) {		syslog(LOG_ERR, "authdes_seccreate: out of memory");		goto failed;	}	if (timehost != NULL) {		ad->ad_timehost = (char *)mem_alloc(strlen(timehost) + 1);		if (ad->ad_timehost == NULL) {			syslog(LOG_ERR, "authdes_seccreate: out of memory");			goto failed;		}		memcpy(ad->ad_timehost, timehost, strlen(timehost) + 1);		ad->ad_dosync = TRUE;	} else if (srvr != NULL) {		ad->ad_nis_srvr = srvr;	/* transient */		ad->ad_dosync = TRUE;	} else {		ad->ad_dosync = FALSE;	}	memcpy(ad->ad_fullname, namebuf, ad->ad_fullnamelen + 1);	memcpy(ad->ad_servername, servername, ad->ad_servernamelen + 1);	ad->ad_window = window;	if (ckey == NULL) {		if (key_gendes(&auth->ah_key) < 0) {			syslog(LOG_ERR,	    "authdes_seccreate: keyserv(1m) is unable to generate session key");			goto failed;		}	} else {		auth->ah_key = *ckey;	}	/*	 * Set up auth handle	 */	auth->ah_cred.oa_flavor = AUTH_DES;	auth->ah_verf.oa_flavor = AUTH_DES;	auth->ah_ops = authdes_ops();	auth->ah_private = (caddr_t)ad;	if (!authdes_refresh(auth, NULL)) {		goto failed;	}	ad->ad_nis_srvr = NULL; /* not needed any longer */	return (auth);failed:	if (auth)		FREE(auth, sizeof (AUTH));	if (ad) {		if (ad->ad_fullname)			FREE(ad->ad_fullname, ad->ad_fullnamelen + 1);		if (ad->ad_servername)			FREE(ad->ad_servername, ad->ad_servernamelen + 1);		if (ad->ad_timehost)			FREE(ad->ad_timehost, strlen(ad->ad_timehost) + 1);		if (ad->ad_netid)			FREE(ad->ad_netid, strlen(ad->ad_netid) + 1);		if (ad->ad_uaddr)			FREE(ad->ad_uaddr, strlen(ad->ad_uaddr) + 1);//.........这里部分代码省略.........
开发者ID:MattDooner,项目名称:freebsd-west,代码行数:101,


示例10: nfsx_init

static intnfsx_init(mntfs *mf){	/*	 * mf_info has the form:	 *   host:/prefix/path,sub,sub,sub	 */	int i;	int glob_error;	struct nfsx *nx;	int asked_for_wakeup = 0;	nx = (struct nfsx *) mf->mf_private;	if (nx == 0) {		char **ivec;		char *info = 0;		char *host;		char *pref;		int error = 0;		info = strdup(mf->mf_info);		host = strchr(info, ':');		if (!host) {			error = EINVAL;			goto errexit;		}		pref = host+1;		host = info;		/*		 * Split the prefix off from the suffices		 */		ivec = strsplit(pref, ',', '/'');		/*		 * Count array size		 */		for (i = 0; ivec[i]; i++)			;		nx = ALLOC(nfsx);		mf->mf_private = nx;		mf->mf_prfree = nfsx_prfree;		nx->nx_c = i - 1;	/* i-1 because we don't want the prefix */		nx->nx_v = xreallocarray(NULL, nx->nx_c, sizeof *nx->nx_v);		{ char *mp = 0;		  char *xinfo = 0;		  char *fs = mf->mf_fo->opt_fs;		  char *rfs = 0;		  for (i = 0; i < nx->nx_c; i++) {			char *path = ivec[i+1];			rfs = str3cat(rfs, pref, "/", path);			/*			 * Determine the mount point.			 * If this is the root, then don't remove			 * the trailing slash to avoid mntfs name clashes.			 */			mp = str3cat(mp, fs, "/", rfs);			normalize_slash(mp);			deslashify(mp);			/*			 * Determine the mount info			 */			xinfo = str3cat(xinfo, host, *path == '/' ? "" : "/", path);			normalize_slash(xinfo);			if (pref[1] != '/0')				deslashify(xinfo);#ifdef DEBUG			dlog("nfsx: init mount for %s on %s", xinfo, mp);#endif			nx->nx_v[i].n_error = -1;			nx->nx_v[i].n_mnt = find_mntfs(&nfs_ops, mf->mf_fo, mp, xinfo, "", mf->mf_mopts, mf->mf_remopts);		  }		  free(rfs);		  free(mp);		  free(xinfo);		}		free(ivec);errexit:		free(info);		if (error)			return error;	}	/*	 * Iterate through the mntfs's and call	 * the underlying init routine on each	 */	glob_error = 0;	for (i = 0; i < nx->nx_c; i++) {		nfsx_mnt *n = &nx->nx_v[i];		mntfs *m = n->n_mnt;		int error = (*m->mf_ops->fs_init)(m);		/*		 * If HARD_NFSX_ERRORS is defined, make any		 * initialisation failure a hard error and//.........这里部分代码省略.........
开发者ID:ajinkya93,项目名称:OpenBSD,代码行数:101,


示例11: DescriptorPool_alloc

/* * call-seq: *     DescriptorPool.new => pool * * Creates a new, empty, descriptor pool. */VALUE DescriptorPool_alloc(VALUE klass) {  DescriptorPool* self = ALLOC(DescriptorPool);  self->symtab = upb_symtab_new(&self->symtab);  return TypedData_Wrap_Struct(klass, &_DescriptorPool_type, self);}
开发者ID:Overruler,项目名称:protobuf,代码行数:11,


示例12: zipOpenNewFileInZip

extern int ZEXPORT zipOpenNewFileInZip (zipFile file, const char* filename, const zip_fileinfo* zipfi,                                         const void* extrafield_local, uInt size_extrafield_local,                                        const void* extrafield_global, uInt size_extrafield_global,                                        const char* comment, int method, int level){    zip_internal* zi;    uInt size_filename;    uInt size_comment;    uInt i;    int err = ZIP_OK;    if (file == NULL)        return ZIP_PARAMERROR;    if ((method!=0) && (method!=Z_DEFLATED))        return ZIP_PARAMERROR;    zi = (zip_internal*)file;    if (zi->in_opened_file_inzip == 1)    {        err = zipCloseFileInZip (file);        if (err != ZIP_OK)            return err;    }    if (filename==NULL)        filename="-";    if (comment==NULL)        size_comment = 0;    else        size_comment = strlen(comment);    size_filename = strlen(filename);    if (zipfi == NULL)        zi->ci.dosDate = 0;    else    {        if (zipfi->dosDate != 0)            zi->ci.dosDate = zipfi->dosDate;        else zi->ci.dosDate = ziplocal_TmzDateToDosDate(&zipfi->tmz_date,zipfi->dosDate);    }    zi->ci.flag = 0;    if ((level==8) || (level==9))      zi->ci.flag |= 2;    if ((level==2))      zi->ci.flag |= 4;    if ((level==1))      zi->ci.flag |= 6;    zi->ci.crc32 = 0;    zi->ci.method = method;    zi->ci.stream_initialised = 0;    zi->ci.pos_in_buffered_data = 0;    zi->ci.pos_local_header = ftell(zi->filezip);    zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename +                                       size_extrafield_global + size_comment;    zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader);    ziplocal_putValue_inmemory(zi->ci.central_header,(uLong)CENTRALHEADERMAGIC,4);    /* version info */    ziplocal_putValue_inmemory(zi->ci.central_header+4,(uLong)VERSIONMADEBY,2);    ziplocal_putValue_inmemory(zi->ci.central_header+6,(uLong)20,2);    ziplocal_putValue_inmemory(zi->ci.central_header+8,(uLong)zi->ci.flag,2);    ziplocal_putValue_inmemory(zi->ci.central_header+10,(uLong)zi->ci.method,2);    ziplocal_putValue_inmemory(zi->ci.central_header+12,(uLong)zi->ci.dosDate,4);    ziplocal_putValue_inmemory(zi->ci.central_header+16,(uLong)0,4); /*crc*/    ziplocal_putValue_inmemory(zi->ci.central_header+20,(uLong)0,4); /*compr size*/    ziplocal_putValue_inmemory(zi->ci.central_header+24,(uLong)0,4); /*uncompr size*/    ziplocal_putValue_inmemory(zi->ci.central_header+28,(uLong)size_filename,2);    ziplocal_putValue_inmemory(zi->ci.central_header+30,(uLong)size_extrafield_global,2);    ziplocal_putValue_inmemory(zi->ci.central_header+32,(uLong)size_comment,2);    ziplocal_putValue_inmemory(zi->ci.central_header+34,(uLong)0,2); /*disk nm start*/    if (zipfi==NULL)        ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)0,2);     else        ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)zipfi->internal_fa,2);     if (zipfi==NULL)        ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)0,4);     else        ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)zipfi->external_fa,4);    ziplocal_putValue_inmemory(zi->ci.central_header+42,(uLong)zi->ci.pos_local_header,4);    for (i=0;i<size_filename;i++)        *(zi->ci.central_header+SIZECENTRALHEADER+i) = *(filename+i);    for (i=0;i<size_extrafield_global;i++)        *(zi->ci.central_header+SIZECENTRALHEADER+size_filename+i) =              *(((const char*)extrafield_global)+i);    for (i=0;i<size_comment;i++)        *(zi->ci.central_header+SIZECENTRALHEADER+size_filename+              size_extrafield_global+i) = *(comment+i);    if (zi->ci.central_header == NULL)//.........这里部分代码省略.........
开发者ID:Anonymous2,项目名称:project64,代码行数:101,


示例13: sizeof

//.........这里部分代码省略.........    }  		    /* move dst */    if (VAL_IS_FLOAT(MOVE_DST(pc)))      count += sizeof(meld_float);    else if (VAL_IS_INT(MOVE_DST(pc)))      count += sizeof(meld_int);    else if (VAL_IS_FIELD(MOVE_DST(pc)))      count += 2;    else if (VAL_IS_REVERSE(MOVE_DST(pc)))      count += 2;    else if (VAL_IS_REG(MOVE_DST(pc)))      {} /* nothing */    else {      assert(0);      exit(1);    }    return pc+count;  }  else if(ITER(pc)) {        pc += ITER_BASE;        if(ITER_MATCH_NONE(pc))      pc += 2;    else {      unsigned char *old;      while(1) {        old = pc;	if (VAL_IS_FLOAT(ITER_MATCH_VAL(pc)))	  pc += sizeof(meld_float);	else if (VAL_IS_INT(ITER_MATCH_VAL(pc)))	  pc += sizeof(meld_int);	else if (VAL_IS_FIELD(ITER_MATCH_VAL(pc)))	  pc += 2;	else if (VAL_IS_REVERSE(ITER_MATCH_VAL(pc)))	  pc += 2;	else {	  assert(0);	  exit(1);	}        pc += 2;        if(ITER_MATCH_END(old))          break;      }    }    return pc;  } else if (ALLOC(pc)) {    int count = 2;    if (VAL_IS_INT(ALLOC_DST(pc)))      count += sizeof(meld_int);    else if	(VAL_IS_FLOAT(ALLOC_DST(pc)))      count += sizeof(meld_float);    else if (VAL_IS_FIELD(ALLOC_DST(pc)))      count += 2;    else if (VAL_IS_REG(ALLOC_DST(pc)))      {} /* nothing */    else if (VAL_IS_REVERSE(ALLOC_DST(pc))) {      count += 2;      assert(0);      exit(1);    } else {      assert(0);      exit(1);    }    return pc+count;  }  else if (CALL(pc)) {    int numArgs = CALL_ARGS(pc);    int i;		    for (i = 0, pc+=2; i < numArgs; i++, pc++) {      if (VAL_IS_FLOAT(CALL_VAL(pc)))        pc += sizeof(meld_float);      else if (VAL_IS_INT(CALL_VAL(pc)))	pc += sizeof(meld_int);      else if (VAL_IS_FIELD(CALL_VAL(pc)))	pc += 2;      else if (VAL_IS_REVERSE(CALL_VAL(pc))) {	pc += 2;	assert(0);	exit(1);      }    }    return pc;  }  else if (IF(pc)) {    return pc+IF_BASE;  }  else {    return pc+1;  }}
开发者ID:pthalamy,项目名称:bench,代码行数:101,


示例14: silk_encode_pulses

/* Encode quantization indices of excitation */void silk_encode_pulses(    ec_enc                      *psRangeEnc,                    /* I/O  compressor data structure                   */    const opus_int              signalType,                     /* I    Signal type                                 */    const opus_int              quantOffsetType,                /* I    quantOffsetType                             */    opus_int8                   pulses[],                       /* I    quantization indices                        */    const opus_int              frame_length                    /* I    Frame length                                */){    opus_int   i, k, j, iter, bit, nLS, scale_down, RateLevelIndex = 0;    opus_int32 abs_q, minSumBits_Q5, sumBits_Q5;    VARDECL( opus_int, abs_pulses );    VARDECL( opus_int, sum_pulses );    VARDECL( opus_int, nRshifts );    opus_int   pulses_comb[ 8 ];    opus_int   *abs_pulses_ptr;    const opus_int8 *pulses_ptr;    const opus_uint8 *cdf_ptr;    const opus_uint8 *nBits_ptr;    SAVE_STACK;    silk_memset( pulses_comb, 0, 8 * sizeof( opus_int ) ); /* Fixing Valgrind reported problem*/    /****************************/    /* Prepare for shell coding */    /****************************/    /* Calculate number of shell blocks */    silk_assert( 1 << LOG2_SHELL_CODEC_FRAME_LENGTH == SHELL_CODEC_FRAME_LENGTH );    iter = silk_RSHIFT( frame_length, LOG2_SHELL_CODEC_FRAME_LENGTH );    if( iter * SHELL_CODEC_FRAME_LENGTH < frame_length ) {        silk_assert( frame_length == 12 * 10 ); /* Make sure only happens for 10 ms @ 12 kHz */        iter++;        silk_memset( &pulses[ frame_length ], 0, SHELL_CODEC_FRAME_LENGTH * sizeof(opus_int8));    }    /* Take the absolute value of the pulses */    ALLOC( abs_pulses, iter * SHELL_CODEC_FRAME_LENGTH, opus_int );    silk_assert( !( SHELL_CODEC_FRAME_LENGTH & 3 ) );    for( i = 0; i < iter * SHELL_CODEC_FRAME_LENGTH; i+=4 ) {        abs_pulses[i+0] = ( opus_int )silk_abs( pulses[ i + 0 ] );        abs_pulses[i+1] = ( opus_int )silk_abs( pulses[ i + 1 ] );        abs_pulses[i+2] = ( opus_int )silk_abs( pulses[ i + 2 ] );        abs_pulses[i+3] = ( opus_int )silk_abs( pulses[ i + 3 ] );    }    /* Calc sum pulses per shell code frame */    ALLOC( sum_pulses, iter, opus_int );    ALLOC( nRshifts, iter, opus_int );    abs_pulses_ptr = abs_pulses;    for( i = 0; i < iter; i++ ) {        nRshifts[ i ] = 0;        while( 1 ) {            /* 1+1 -> 2 */            scale_down = combine_and_check( pulses_comb, abs_pulses_ptr, silk_max_pulses_table[ 0 ], 8 );            /* 2+2 -> 4 */            scale_down += combine_and_check( pulses_comb, pulses_comb, silk_max_pulses_table[ 1 ], 4 );            /* 4+4 -> 8 */            scale_down += combine_and_check( pulses_comb, pulses_comb, silk_max_pulses_table[ 2 ], 2 );            /* 8+8 -> 16 */            scale_down += combine_and_check( &sum_pulses[ i ], pulses_comb, silk_max_pulses_table[ 3 ], 1 );            if( scale_down ) {                /* We need to downscale the quantization signal */                nRshifts[ i ]++;                for( k = 0; k < SHELL_CODEC_FRAME_LENGTH; k++ ) {                    abs_pulses_ptr[ k ] = silk_RSHIFT( abs_pulses_ptr[ k ], 1 );                }            } else {                /* Jump out of while(1) loop and go to next shell coding frame */                break;            }        }        abs_pulses_ptr += SHELL_CODEC_FRAME_LENGTH;    }    /**************/    /* Rate level */    /**************/    /* find rate level that leads to fewest bits for coding of pulses per block info */    minSumBits_Q5 = silk_int32_MAX;    for( k = 0; k < N_RATE_LEVELS - 1; k++ ) {        nBits_ptr  = silk_pulses_per_block_BITS_Q5[ k ];        sumBits_Q5 = silk_rate_levels_BITS_Q5[ signalType >> 1 ][ k ];        for( i = 0; i < iter; i++ ) {            if( nRshifts[ i ] > 0 ) {                sumBits_Q5 += nBits_ptr[ MAX_PULSES + 1 ];            } else {                sumBits_Q5 += nBits_ptr[ sum_pulses[ i ] ];            }        }        if( sumBits_Q5 < minSumBits_Q5 ) {            minSumBits_Q5 = sumBits_Q5;            RateLevelIndex = k;        }    }    ec_enc_icdf( psRangeEnc, RateLevelIndex, silk_rate_levels_iCDF[ signalType >> 1 ], 8 );    /***************************************************/    /* Sum-Weighted-Pulses Encoding                    *///.........这里部分代码省略.........
开发者ID:2k13yr,项目名称:telegram-1,代码行数:101,


示例15: AllocReversedList

value_t AllocReversedList( zone_t zone, value_t listObj ){	struct closure *out = ALLOC( List_reverse_func, LIST_REVERSE_SLOT_COUNT );	out->slots[LIST_REVERSE_LIST_SLOT] = listObj;	return out;}
开发者ID:marssaxman,项目名称:radian,代码行数:6,


示例16: authdes_pk_create

AUTH *authdes_pk_create (const char *servername, netobj *pkey, u_int window,		   struct sockaddr *syncaddr, des_block *ckey){  AUTH *auth;  struct ad_private *ad;  char namebuf[MAXNETNAMELEN + 1];  /*   * Allocate everything now   */  auth = ALLOC (AUTH);  ad = ALLOC (struct ad_private);  if (auth == NULL || ad == NULL)    {      debug ("authdes_create: out of memory");      goto failed;    }  memset (ad, 0, sizeof (struct ad_private));  memcpy (ad->ad_pkey, pkey->n_bytes, pkey->n_len);  if (!getnetname (namebuf))    goto failed;  ad->ad_fullnamelen = RNDUP (strlen (namebuf));  ad->ad_fullname = mem_alloc (ad->ad_fullnamelen + 1);  ad->ad_servernamelen = strlen (servername);  ad->ad_servername = mem_alloc (ad->ad_servernamelen + 1);  if (ad->ad_fullname == NULL || ad->ad_servername == NULL)    {      debug ("authdes_create: out of memory");      goto failed;    }  /*   * Set up private data   */  memcpy (ad->ad_fullname, namebuf, ad->ad_fullnamelen + 1);  memcpy (ad->ad_servername, servername, ad->ad_servernamelen + 1);  ad->ad_timediff.tv_sec = ad->ad_timediff.tv_usec = 0;  if (syncaddr != NULL)    {      ad->ad_syncaddr = *syncaddr;      ad->ad_dosync = TRUE;    }  else    ad->ad_dosync = FALSE;  ad->ad_window = window;  if (ckey == NULL)    {      if (key_gendes (&auth->ah_key) < 0)	{	  debug ("authdes_create: unable to gen conversation key");	  goto failed;	}    }  else    auth->ah_key = *ckey;  /*   * Set up auth handle   */  auth->ah_cred.oa_flavor = AUTH_DES;  auth->ah_verf.oa_flavor = AUTH_DES;  auth->ah_ops = (struct auth_ops *) &authdes_ops;  auth->ah_private = (caddr_t) ad;  if (!authdes_refresh (auth))    goto failed;  return auth;failed:  if (auth != NULL)    FREE (auth, sizeof (AUTH));  if (ad != NULL)    {      if (ad->ad_fullname != NULL)	FREE (ad->ad_fullname, ad->ad_fullnamelen + 1);      if (ad->ad_servername != NULL)	FREE (ad->ad_servername, ad->ad_servernamelen + 1);      FREE (ad, sizeof (struct ad_private));    }  return NULL;}
开发者ID:bminor,项目名称:glibc,代码行数:88,


示例17: zipOpen2

extern zipFile ZEXPORT zipOpen2 (    const char *pathname,    int append,    zipcharpc* globalcomment,    zlib_filefunc_def* pzlib_filefunc_def){    zip_internal ziinit;    zip_internal* zi;    int err=ZIP_OK;    if (pzlib_filefunc_def==NULL)        fill_fopen_filefunc(&ziinit.z_filefunc);    else        ziinit.z_filefunc = *pzlib_filefunc_def;    ziinit.filestream = (*(ziinit.z_filefunc.zopen_file))                 (ziinit.z_filefunc.opaque,                  pathname,                  (append == APPEND_STATUS_CREATE) ?                  (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_CREATE) :                    (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_EXISTING));    if (ziinit.filestream == NULL)        return NULL;    ziinit.begin_pos = ZTELL(ziinit.z_filefunc,ziinit.filestream);    ziinit.in_opened_file_inzip = 0;    ziinit.ci.stream_initialised = 0;    ziinit.number_entry = 0;    ziinit.add_position_when_writting_offset = 0;    init_linkedlist(&(ziinit.central_dir));    zi = (zip_internal*)ALLOC(sizeof(zip_internal));    if (zi==NULL)    {        ZCLOSE(ziinit.z_filefunc,ziinit.filestream);        return NULL;    }    /* now we add file in a zipfile */#    ifndef NO_ADDFILEINEXISTINGZIP    if (append == APPEND_STATUS_ADDINZIP)    {        uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/        uLong size_central_dir;     /* size of the central directory  */        uLong offset_central_dir;   /* offset of start of central directory */        uLong central_pos,uL;        uLong number_disk;          /* number of the current dist, used for                                    spaning ZIP, unsupported, always 0*/        uLong number_disk_with_CD;  /* number the the disk with central dir, used                                    for spaning ZIP, unsupported, always 0*/        uLong number_entry;        uLong number_entry_CD;      /* total number of entries in                                    the central dir                                    (same than number_entry on nospan) */        uLong size_comment;        central_pos = ziplocal_SearchCentralDir(&ziinit.z_filefunc,ziinit.filestream);        if (central_pos==0)            err=ZIP_ERRNO;        if (ZSEEK(ziinit.z_filefunc, ziinit.filestream,                                        central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)            err=ZIP_ERRNO;        /* the signature, already checked */        if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&uL)!=ZIP_OK)            err=ZIP_ERRNO;        /* number of this disk */        if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_disk)!=ZIP_OK)            err=ZIP_ERRNO;        /* number of the disk with the start of the central directory */        if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_disk_with_CD)!=ZIP_OK)            err=ZIP_ERRNO;        /* total number of entries in the central dir on this disk */        if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_entry)!=ZIP_OK)            err=ZIP_ERRNO;        /* total number of entries in the central dir */        if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_entry_CD)!=ZIP_OK)            err=ZIP_ERRNO;        if ((number_entry_CD!=number_entry) ||            (number_disk_with_CD!=0) ||            (number_disk!=0))            err=ZIP_BADZIPFILE;        /* size of the central directory */        if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&size_central_dir)!=ZIP_OK)            err=ZIP_ERRNO;        /* offset of start of central directory with respect to the            starting disk number */        if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&offset_central_dir)!=ZIP_OK)//.........这里部分代码省略.........
开发者ID:AbsolutK,项目名称:domoticz,代码行数:101,


示例18: init_tgs_req

static krb5_error_codeinit_tgs_req (krb5_context context,	      krb5_ccache ccache,	      krb5_addresses *addresses,	      krb5_kdc_flags flags,	      Ticket *second_ticket,	      krb5_creds *in_creds,	      krb5_creds *krbtgt,	      unsigned nonce,	      const METHOD_DATA *padata,	      krb5_keyblock **subkey,	      TGS_REQ *t,	      krb5_key_usage usage){    krb5_error_code ret = 0;    memset(t, 0, sizeof(*t));    t->pvno = 5;    t->msg_type = krb_tgs_req;    if (in_creds->session.keytype) {	ALLOC_SEQ(&t->req_body.etype, 1);	if(t->req_body.etype.val == NULL) {	    ret = ENOMEM;	    krb5_set_error_string(context, "malloc: out of memory");	    goto fail;	}	t->req_body.etype.val[0] = in_creds->session.keytype;    } else {	ret = krb5_init_etype(context, 			      &t->req_body.etype.len, 			      &t->req_body.etype.val, 			      NULL);    }    if (ret)	goto fail;    t->req_body.addresses = addresses;    t->req_body.kdc_options = flags.b;    ret = copy_Realm(&in_creds->server->realm, &t->req_body.realm);    if (ret)	goto fail;    ALLOC(t->req_body.sname, 1);    if (t->req_body.sname == NULL) {	ret = ENOMEM;	krb5_set_error_string(context, "malloc: out of memory");	goto fail;    }    /* some versions of some code might require that the client be       present in TGS-REQs, but this is clearly against the spec */    ret = copy_PrincipalName(&in_creds->server->name, t->req_body.sname);    if (ret)	goto fail;    /* req_body.till should be NULL if there is no endtime specified,       but old MIT code (like DCE secd) doesn't like that */    ALLOC(t->req_body.till, 1);    if(t->req_body.till == NULL){	ret = ENOMEM;	krb5_set_error_string(context, "malloc: out of memory");	goto fail;    }    *t->req_body.till = in_creds->times.endtime;        t->req_body.nonce = nonce;    if(second_ticket){	ALLOC(t->req_body.additional_tickets, 1);	if (t->req_body.additional_tickets == NULL) {	    ret = ENOMEM;	    krb5_set_error_string(context, "malloc: out of memory");	    goto fail;	}	ALLOC_SEQ(t->req_body.additional_tickets, 1);	if (t->req_body.additional_tickets->val == NULL) {	    ret = ENOMEM;	    krb5_set_error_string(context, "malloc: out of memory");	    goto fail;	}	ret = copy_Ticket(second_ticket, t->req_body.additional_tickets->val); 	if (ret)	    goto fail;    }    ALLOC(t->padata, 1);    if (t->padata == NULL) {	ret = ENOMEM;	krb5_set_error_string(context, "malloc: out of memory");	goto fail;    }    ALLOC_SEQ(t->padata, 1 + padata->len);    if (t->padata->val == NULL) {	ret = ENOMEM;	krb5_set_error_string(context, "malloc: out of memory");	goto fail;    }    {	int i;	for (i = 0; i < padata->len; i++) {	    ret = copy_PA_DATA(&padata->val[i], &t->padata->val[i + 1]);	    if (ret) {		krb5_set_error_string(context, "malloc: out of memory");//.........这里部分代码省略.........
开发者ID:2014-class,项目名称:freerouter,代码行数:101,


示例19: zipOpenNewFileInZip3

extern int ZEXPORT zipOpenNewFileInZip3 (    zipFile file,    const char* filename,    const zip_fileinfo* zipfi,    const void* extrafield_local,    uInt size_extrafield_local,    const void* extrafield_global,    uInt size_extrafield_global,    const char* comment,    int method,    int level,    int raw,    int windowBits,    int memLevel,    int strategy,    const char* password,    uLong crcForCrypting){    zip_internal* zi;    uInt size_filename;    uInt size_comment;    uInt i;    int err = ZIP_OK;#    ifdef NOCRYPT    if (password != NULL)        return ZIP_PARAMERROR;#    endif    if (file == NULL)        return ZIP_PARAMERROR;    if ((method!=0) && (method!=Z_DEFLATED))        return ZIP_PARAMERROR;    zi = (zip_internal*)file;    if (zi->in_opened_file_inzip == 1)    {        err = zipCloseFileInZip (file);        if (err != ZIP_OK)            return err;    }    if (filename==NULL)        filename="-";    if (comment==NULL)        size_comment = 0;    else        size_comment = strlen(comment);    size_filename = strlen(filename);    if (zipfi == NULL)        zi->ci.dosDate = 0;    else    {        if (zipfi->dosDate != 0)            zi->ci.dosDate = zipfi->dosDate;        else zi->ci.dosDate = ziplocal_TmzDateToDosDate(&zipfi->tmz_date,zipfi->dosDate);    }    zi->ci.flag = 0;    if ((level==8) || (level==9))      zi->ci.flag |= 2;    if ((level==2))      zi->ci.flag |= 4;    if ((level==1))      zi->ci.flag |= 6;    if (password != NULL)      zi->ci.flag |= 1;    zi->ci.crc32 = 0;    zi->ci.method = method;    zi->ci.encrypt = 0;    zi->ci.stream_initialised = 0;    zi->ci.pos_in_buffered_data = 0;    zi->ci.raw = raw;    zi->ci.pos_local_header = ZTELL(zi->z_filefunc,zi->filestream) ;    zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename +                                      size_extrafield_global + size_comment;    zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader);    ziplocal_putValue_inmemory(zi->ci.central_header,(uLong)CENTRALHEADERMAGIC,4);    /* version info */    ziplocal_putValue_inmemory(zi->ci.central_header+4,(uLong)VERSIONMADEBY,2);    ziplocal_putValue_inmemory(zi->ci.central_header+6,(uLong)20,2);    ziplocal_putValue_inmemory(zi->ci.central_header+8,(uLong)zi->ci.flag,2);    ziplocal_putValue_inmemory(zi->ci.central_header+10,(uLong)zi->ci.method,2);    ziplocal_putValue_inmemory(zi->ci.central_header+12,(uLong)zi->ci.dosDate,4);    ziplocal_putValue_inmemory(zi->ci.central_header+16,(uLong)0,4); /*crc*/    ziplocal_putValue_inmemory(zi->ci.central_header+20,(uLong)0,4); /*compr size*/    ziplocal_putValue_inmemory(zi->ci.central_header+24,(uLong)0,4); /*uncompr size*/    ziplocal_putValue_inmemory(zi->ci.central_header+28,(uLong)size_filename,2);    ziplocal_putValue_inmemory(zi->ci.central_header+30,(uLong)size_extrafield_global,2);    ziplocal_putValue_inmemory(zi->ci.central_header+32,(uLong)size_comment,2);    ziplocal_putValue_inmemory(zi->ci.central_header+34,(uLong)0,2); /*disk nm start*/    if (zipfi==NULL)//.........这里部分代码省略.........
开发者ID:AbsolutK,项目名称:domoticz,代码行数:101,


示例20: silk_setup_resamplers

static opus_int silk_setup_resamplers(    silk_encoder_state_Fxx          *psEnc,             /* I/O                      */    opus_int                         fs_kHz              /* I                        */){    opus_int   ret = SILK_NO_ERROR;    SAVE_STACK;    if( psEnc->sCmn.fs_kHz != fs_kHz || psEnc->sCmn.prev_API_fs_Hz != psEnc->sCmn.API_fs_Hz )    {        if( psEnc->sCmn.fs_kHz == 0 ) {            /* Initialize the resampler for enc_API.c preparing resampling from API_fs_Hz to fs_kHz */            ret += silk_resampler_init( &psEnc->sCmn.resampler_state, psEnc->sCmn.API_fs_Hz, fs_kHz * 1000, 1 );        } else {            VARDECL( opus_int16, x_buf_API_fs_Hz );            VARDECL( silk_resampler_state_struct, temp_resampler_state );#ifdef FIXED_POINT            opus_int16 *x_bufFIX = psEnc->x_buf;#else            VARDECL( opus_int16, x_bufFIX );            opus_int32 new_buf_samples;#endif            opus_int32 api_buf_samples;            opus_int32 old_buf_samples;            opus_int32 buf_length_ms;            buf_length_ms = silk_LSHIFT( psEnc->sCmn.nb_subfr * 5, 1 ) + LA_SHAPE_MS;            old_buf_samples = buf_length_ms * psEnc->sCmn.fs_kHz;#ifndef FIXED_POINT            new_buf_samples = buf_length_ms * fs_kHz;            ALLOC( x_bufFIX, silk_max( old_buf_samples, new_buf_samples ),                   opus_int16 );            silk_float2short_array( x_bufFIX, psEnc->x_buf, old_buf_samples );#endif            /* Initialize resampler for temporary resampling of x_buf data to API_fs_Hz */            ALLOC( temp_resampler_state, 1, silk_resampler_state_struct );            ret += silk_resampler_init( temp_resampler_state, silk_SMULBB( psEnc->sCmn.fs_kHz, 1000 ), psEnc->sCmn.API_fs_Hz, 0 );            /* Calculate number of samples to temporarily upsample */            api_buf_samples = buf_length_ms * silk_DIV32_16( psEnc->sCmn.API_fs_Hz, 1000 );            /* Temporary resampling of x_buf data to API_fs_Hz */            ALLOC( x_buf_API_fs_Hz, api_buf_samples, opus_int16 );            ret += silk_resampler( temp_resampler_state, x_buf_API_fs_Hz, x_bufFIX, old_buf_samples );            /* Initialize the resampler for enc_API.c preparing resampling from API_fs_Hz to fs_kHz */            ret += silk_resampler_init( &psEnc->sCmn.resampler_state, psEnc->sCmn.API_fs_Hz, silk_SMULBB( fs_kHz, 1000 ), 1 );            /* Correct resampler state by resampling buffered data from API_fs_Hz to fs_kHz */            ret += silk_resampler( &psEnc->sCmn.resampler_state, x_bufFIX, x_buf_API_fs_Hz, api_buf_samples );#ifndef FIXED_POINT            silk_short2float_array( psEnc->x_buf, x_bufFIX, new_buf_samples);#endif        }    }    psEnc->sCmn.prev_API_fs_Hz = psEnc->sCmn.API_fs_Hz;    RESTORE_STACK;    return ret;}
开发者ID:62gs8ha,项目名称:batphone,代码行数:64,


示例21: silk_find_pitch_lags_FIX

/* Find pitch lags */void silk_find_pitch_lags_FIX(    silk_encoder_state_FIX          *psEnc,                                 /* I/O  encoder state                                                               */    silk_encoder_control_FIX        *psEncCtrl,                             /* I/O  encoder control                                                             */    opus_int16                      res[],                                  /* O    residual                                                                    */    const opus_int16                x[],                                    /* I    Speech signal                                                               */    int                             arch                                    /* I    Run-time architecture                                                       */){    opus_int   buf_len, i, scale;    opus_int32 thrhld_Q13, res_nrg;    const opus_int16 *x_buf, *x_buf_ptr;    VARDECL(opus_int16, Wsig);    opus_int16 *Wsig_ptr;    opus_int32 auto_corr[ MAX_FIND_PITCH_LPC_ORDER + 1 ];    opus_int16 rc_Q15[    MAX_FIND_PITCH_LPC_ORDER ];    opus_int32 A_Q24[     MAX_FIND_PITCH_LPC_ORDER ];    opus_int16 A_Q12[     MAX_FIND_PITCH_LPC_ORDER ];    SAVE_STACK;    /******************************************/    /* Set up buffer lengths etc based on Fs  */    /******************************************/    buf_len = psEnc->sCmn.la_pitch + psEnc->sCmn.frame_length + psEnc->sCmn.ltp_mem_length;    /* Safety check */    silk_assert(buf_len >= psEnc->sCmn.pitch_LPC_win_length);    x_buf = x - psEnc->sCmn.ltp_mem_length;    /*************************************/    /* Estimate LPC AR coefficients      */    /*************************************/    /* Calculate windowed signal */    ALLOC(Wsig, psEnc->sCmn.pitch_LPC_win_length, opus_int16);    /* First LA_LTP samples */    x_buf_ptr = x_buf + buf_len - psEnc->sCmn.pitch_LPC_win_length;    Wsig_ptr  = Wsig;    silk_apply_sine_window(Wsig_ptr, x_buf_ptr, 1, psEnc->sCmn.la_pitch);    /* Middle un - windowed samples */    Wsig_ptr  += psEnc->sCmn.la_pitch;    x_buf_ptr += psEnc->sCmn.la_pitch;    silk_memcpy(Wsig_ptr, x_buf_ptr, (psEnc->sCmn.pitch_LPC_win_length - silk_LSHIFT(psEnc->sCmn.la_pitch, 1)) * sizeof(opus_int16));    /* Last LA_LTP samples */    Wsig_ptr  += psEnc->sCmn.pitch_LPC_win_length - silk_LSHIFT(psEnc->sCmn.la_pitch, 1);    x_buf_ptr += psEnc->sCmn.pitch_LPC_win_length - silk_LSHIFT(psEnc->sCmn.la_pitch, 1);    silk_apply_sine_window(Wsig_ptr, x_buf_ptr, 2, psEnc->sCmn.la_pitch);    /* Calculate autocorrelation sequence */    silk_autocorr(auto_corr, &scale, Wsig, psEnc->sCmn.pitch_LPC_win_length, psEnc->sCmn.pitchEstimationLPCOrder + 1, arch);    /* Add white noise, as fraction of energy */    auto_corr[ 0 ] = silk_SMLAWB(auto_corr[ 0 ], auto_corr[ 0 ], SILK_FIX_CONST(FIND_PITCH_WHITE_NOISE_FRACTION, 16)) + 1;    /* Calculate the reflection coefficients using schur */    res_nrg = silk_schur(rc_Q15, auto_corr, psEnc->sCmn.pitchEstimationLPCOrder);    /* Prediction gain */    psEncCtrl->predGain_Q16 = silk_DIV32_varQ(auto_corr[ 0 ], silk_max_int(res_nrg, 1), 16);    /* Convert reflection coefficients to prediction coefficients */    silk_k2a(A_Q24, rc_Q15, psEnc->sCmn.pitchEstimationLPCOrder);    /* Convert From 32 bit Q24 to 16 bit Q12 coefs */    for(i = 0; i < psEnc->sCmn.pitchEstimationLPCOrder; i++) {        A_Q12[ i ] = (opus_int16)silk_SAT16(silk_RSHIFT(A_Q24[ i ], 12));    }    /* Do BWE */    silk_bwexpander(A_Q12, psEnc->sCmn.pitchEstimationLPCOrder, SILK_FIX_CONST(FIND_PITCH_BANDWIDTH_EXPANSION, 16));    /*****************************************/    /* LPC analysis filtering                */    /*****************************************/    silk_LPC_analysis_filter(res, x_buf, A_Q12, buf_len, psEnc->sCmn.pitchEstimationLPCOrder, psEnc->sCmn.arch);    if(psEnc->sCmn.indices.signalType != TYPE_NO_VOICE_ACTIVITY && psEnc->sCmn.first_frame_after_reset == 0) {        /* Threshold for pitch estimator */        thrhld_Q13 = SILK_FIX_CONST(0.6, 13);        thrhld_Q13 = silk_SMLABB(thrhld_Q13, SILK_FIX_CONST(-0.004, 13), psEnc->sCmn.pitchEstimationLPCOrder);        thrhld_Q13 = silk_SMLAWB(thrhld_Q13, SILK_FIX_CONST(-0.1,   21 ), psEnc->sCmn.speech_activity_Q8);        thrhld_Q13 = silk_SMLABB(thrhld_Q13, SILK_FIX_CONST(-0.15,  13), silk_RSHIFT(psEnc->sCmn.prevSignalType, 1));        thrhld_Q13 = silk_SMLAWB(thrhld_Q13, SILK_FIX_CONST(-0.1,   14), psEnc->sCmn.input_tilt_Q15);        thrhld_Q13 = silk_SAT16( thrhld_Q13);        /*****************************************/        /* Call pitch estimator                  */        /*****************************************/        if(silk_pitch_analysis_core(res, psEncCtrl->pitchL, &psEnc->sCmn.indices.lagIndex, &psEnc->sCmn.indices.contourIndex,                &psEnc->LTPCorr_Q15, psEnc->sCmn.prevLag, psEnc->sCmn.pitchEstimationThreshold_Q16,                (opus_int)thrhld_Q13, psEnc->sCmn.fs_kHz, psEnc->sCmn.pitchEstimationComplexity, psEnc->sCmn.nb_subfr,                psEnc->sCmn.arch) == 0)        {            psEnc->sCmn.indices.signalType = TYPE_VOICED;        } else {//.........这里部分代码省略.........
开发者ID:ioid3-games,项目名称:ioid3-rtcw,代码行数:101,


示例22: cuddSymmSiftingConv

/**  @brief Symmetric sifting to convergence algorithm.  @details Assumes that no dead nodes are present.    <ol>    <li> Order all the variables according to the number of entries in    each unique subtable.    <li> Sift the variable up and down, remembering each time the total    size of the %DD heap and grouping variables that are symmetric.    <li> Select the best permutation.    <li> Repeat 3 and 4 for all variables.    <li> Repeat 1-4 until no further improvement.    </ol>  @return 1 plus the number of symmetric variables if successful; 0  otherwise.  @sideeffect None  @see cuddSymmSifting*/intcuddSymmSiftingConv(  DdManager * table,  int  lower,  int  upper){    int		i;    IndexKey	*var;    int		size;    int		x;    int		result;    int		symvars;    int		symgroups;    int		classes;    int		initialSize;#ifdef DD_STATS    int		previousSize;#endif    initialSize = (int) (table->keys - table->isolated);    size = table->size;    /* Find order in which to sift variables. */    var = ALLOC(IndexKey,size);    if (var == NULL) {	table->errorCode = CUDD_MEMORY_OUT;	goto ddSymmSiftingConvOutOfMem;    }    for (i = 0; i < size; i++) {	x = table->perm[i];	var[i].index = i;	var[i].keys = table->subtables[x].keys;    }    util_qsort(var,size,sizeof(IndexKey),ddSymmUniqueCompare);    /* Initialize the symmetry of each subtable to itself    ** for first pass of converging symmetric sifting.    */    for (i = lower; i <= upper; i++) {	table->subtables[i].next = i;    }    for (i = 0; i < ddMin(table->siftMaxVar, table->size); i++) {	if (table->ddTotalNumberSwapping >= table->siftMaxSwap)	    break;        if (util_cpu_time() - table->startTime > table->timeLimit) {            table->autoDyn = 0; /* prevent further reordering */            break;        }        if (table->terminationCallback != NULL &&            table->terminationCallback(table->tcbArg)) {            table->autoDyn = 0; /* prevent further reordering */            break;        }	x = table->perm[var[i].index];	if (x < lower || x > upper) continue;	/* Only sift if not in symmetry group already. */	if (table->subtables[x].next == (unsigned) x) {#ifdef DD_STATS          previousSize = (int) (table->keys - table->isolated);#endif	    result = ddSymmSiftingAux(table,x,lower,upper);	    if (!result) goto ddSymmSiftingConvOutOfMem;#ifdef DD_STATS	    if (table->keys < (unsigned) previousSize + table->isolated) {		(void) fprintf(table->out,"-");	    } else if (table->keys > (unsigned) previousSize +		       table->isolated) {		(void) fprintf(table->out,"+");	    } else {		(void) fprintf(table->out,"=");	    }	    fflush(table->out);#endif	}//.........这里部分代码省略.........
开发者ID:VerifiableRobotics,项目名称:slugs,代码行数:101,


示例23: sig_process

static intsig_process(hx509_context context, void *ctx, hx509_cert cert){    struct sigctx *sigctx = ctx;    heim_octet_string buf, sigdata = { 0, NULL };    SignerInfo *signer_info = NULL;    AlgorithmIdentifier digest;    size_t size;    void *ptr;    int ret;    SignedData *sd = &sigctx->sd;    hx509_path path;    memset(&digest, 0, sizeof(digest));    memset(&path, 0, sizeof(path));    if (_hx509_cert_private_key(cert) == NULL) {	hx509_set_error_string(context, 0, HX509_PRIVATE_KEY_MISSING,			       "Private key missing for signing");	return HX509_PRIVATE_KEY_MISSING;    }    if (sigctx->digest_alg) {	ret = copy_AlgorithmIdentifier(sigctx->digest_alg, &digest);	if (ret)	    hx509_clear_error_string(context);    } else {	ret = hx509_crypto_select(context, HX509_SELECT_DIGEST,				  _hx509_cert_private_key(cert), 				  sigctx->peer, &digest);    }    if (ret)	goto out;    /*     * Allocate on more signerInfo and do the signature processing     */    ptr = realloc(sd->signerInfos.val,		  (sd->signerInfos.len + 1) * sizeof(sd->signerInfos.val[0]));    if (ptr == NULL) {	ret = ENOMEM;	goto out;    }    sd->signerInfos.val = ptr;    signer_info = &sd->signerInfos.val[sd->signerInfos.len];    memset(signer_info, 0, sizeof(*signer_info));    signer_info->version = 1;    ret = fill_CMSIdentifier(cert, sigctx->cmsidflag, &signer_info->sid);    if (ret) {	hx509_clear_error_string(context);	goto out;    }			    signer_info->signedAttrs = NULL;    signer_info->unsignedAttrs = NULL;    ret = copy_AlgorithmIdentifier(&digest, &signer_info->digestAlgorithm);    if (ret) {	hx509_clear_error_string(context);	goto out;    }    /*     * If it isn't pkcs7-data send signedAttributes     */    if (der_heim_oid_cmp(sigctx->eContentType, &asn1_oid_id_pkcs7_data) != 0) {	CMSAttributes sa;		heim_octet_string sig;	ALLOC(signer_info->signedAttrs, 1);	if (signer_info->signedAttrs == NULL) {	    ret = ENOMEM;	    goto out;	}	ret = _hx509_create_signature(context,				      NULL,				      &digest,				      &sigctx->content,				      NULL,				      &sig);	if (ret)	    goto out;	ASN1_MALLOC_ENCODE(MessageDigest,			   buf.data,			   buf.length,			   &sig,			   &size,			   ret);	der_free_octet_string(&sig);	if (ret) {	    hx509_clear_error_string(context);	    goto out;//.........这里部分代码省略.........
开发者ID:0x24bin,项目名称:winexe-1,代码行数:101,


示例24: rev_list_merge

rev_list *rev_list_merge (rev_list *head){    int		count = rev_list_count (head);    rev_list	*rl;    rev_list	*l;    rev_ref	*lh, *h;    Tag		*t;    rev_ref	**refs;    int		nref;    ALLOC((rl = calloc (1, sizeof (rev_list))), "rev_list_merge");    ALLOC((refs = calloc (count, sizeof (rev_ref *))), "rev_list_merge");    /*     * Find all of the heads across all of the incoming trees     * Yes, this is currently very inefficient     */    for (l = head; l; l = l->next) {	for (lh = l->heads; lh; lh = lh->next) {	    h = rev_find_head (rl, lh->name);	    if (!h)		rev_list_add_head (rl, NULL, lh->name, lh->degree);	    else if (lh->degree > h->degree)		h->degree = lh->degree;	}    }    /*     * Sort by degree so that finding branch points always works     *///    rl->heads = rev_ref_sel_sort (rl->heads);    rl->heads = rev_ref_tsort (rl->heads, head);    if (!rl->heads)	return NULL;//    for (h = rl->heads; h; h = h->next)//	fprintf (stderr, "head %s (%d)/n",//		 h->name, h->degree);    /*     * Find branch parent relationships     */    for (h = rl->heads; h; h = h->next) {	rev_ref_set_parent (rl, h, head);//	dump_ref_name (stderr, h);//	fprintf (stderr, "/n");    }    /*     * Merge common branches     */    for (h = rl->heads; h; h = h->next) {	/*	 * Locate branch in every tree	 */	nref = 0;	for (l = head; l; l = l->next) {	    lh = rev_find_head (l, h->name);	    if (lh)		refs[nref++] = lh;	}	if (nref)	    rev_branch_merge (refs, nref, h, rl);    }    /*     * Compute 'tail' values     */    rev_list_set_tail (rl);    free(refs);    /*     * Find tag locations     */    for (t = all_tags; t; t = t->next) {	rev_commit **commits = tagged(t);	if (commits)	    rev_tag_search(t, commits, rl);	else	    fprintf (stderr, "lost tag %s/n", t->name);	free(commits);    }    rev_list_validate (rl);    return rl;}
开发者ID:eatnumber1,项目名称:parsecvs,代码行数:80,


示例25: hx509_cms_create_signed

inthx509_cms_create_signed(hx509_context context,			int flags,			const heim_oid *eContentType,			const void *data, size_t length,			const AlgorithmIdentifier *digest_alg,			hx509_certs certs,			hx509_peer_info peer,			hx509_certs anchors,			hx509_certs pool,			heim_octet_string *signed_data){    unsigned int i;    hx509_name name;    int ret;    size_t size;    struct sigctx sigctx;    memset(&sigctx, 0, sizeof(sigctx));    memset(&name, 0, sizeof(name));    if (eContentType == NULL)	eContentType = &asn1_oid_id_pkcs7_data;    sigctx.digest_alg = digest_alg;    sigctx.content.data = rk_UNCONST(data);    sigctx.content.length = length;    sigctx.eContentType = eContentType;    sigctx.peer = peer;    /**     * Use HX509_CMS_SIGNATURE_ID_NAME to preferred use of issuer name     * and serial number if possible. Otherwise subject key identifier     * will preferred.     */    if (flags & HX509_CMS_SIGNATURE_ID_NAME)	sigctx.cmsidflag = CMS_ID_NAME;    else	sigctx.cmsidflag = CMS_ID_SKI;    ret = hx509_certs_init(context, "MEMORY:certs", 0, NULL, &sigctx.certs);    if (ret)	return ret;    sigctx.anchors = anchors;    sigctx.pool = pool;    sigctx.sd.version = CMSVersion_v3;    der_copy_oid(eContentType, &sigctx.sd.encapContentInfo.eContentType);    /**     * Use HX509_CMS_SIGNATURE_DETACHED to create detached signatures.     */    if ((flags & HX509_CMS_SIGNATURE_DETACHED) == 0) {	ALLOC(sigctx.sd.encapContentInfo.eContent, 1);	if (sigctx.sd.encapContentInfo.eContent == NULL) {	    hx509_clear_error_string(context);	    ret = ENOMEM;	    goto out;	}		sigctx.sd.encapContentInfo.eContent->data = malloc(length);	if (sigctx.sd.encapContentInfo.eContent->data == NULL) {	    hx509_clear_error_string(context);	    ret = ENOMEM;	    goto out;	}	memcpy(sigctx.sd.encapContentInfo.eContent->data, data, length);	sigctx.sd.encapContentInfo.eContent->length = length;    }    /**     * Use HX509_CMS_SIGNATURE_NO_SIGNER to create no sigInfo (no     * signatures).     */    if ((flags & HX509_CMS_SIGNATURE_NO_SIGNER) == 0) {	ret = hx509_certs_iter(context, certs, sig_process, &sigctx);	if (ret)	    goto out;    }    if (sigctx.sd.signerInfos.len) {	ALLOC_SEQ(&sigctx.sd.digestAlgorithms, sigctx.sd.signerInfos.len);	if (sigctx.sd.digestAlgorithms.val == NULL) {	    ret = ENOMEM;	    hx509_clear_error_string(context);	    goto out;	}		/* XXX remove dups */	for (i = 0; i < sigctx.sd.signerInfos.len; i++) {	    AlgorithmIdentifier *di =		&sigctx.sd.signerInfos.val[i].digestAlgorithm;	    ret = copy_AlgorithmIdentifier(di,					   &sigctx.sd.digestAlgorithms.val[i]);	    if (ret) {		hx509_clear_error_string(context);		goto out;	    }	}//.........这里部分代码省略.........
开发者ID:0x24bin,项目名称:winexe-1,代码行数:101,


示例26: siop_init

/* * Initialize the device. */intsiop_init(int bus, int dev, int func){	struct siop_adapter tmp;	struct siop_xfer *xfer;	struct scsipi_generic *cmd;	struct scsi_request_sense *sense;	uint32_t reg;	u_long addr;	uint32_t *script;	int slot, id, i;	void *scriptaddr;	u_char *data;	const int clock_div = 3;		/* 53c810 */	slot = PCISlotnum(bus, dev, func);	if (slot == -1)		return ENOENT;	addr = PCIAddress(slot, 1, PCI_MAPREG_TYPE_MEM);	if (addr == 0xffffffff)		return EINVAL;	enablePCI(slot, 0, 1, 1);	script = ALLOC(uint32_t, SIOP_SCRIPT_SIZE);	if (script == NULL)		return ENOMEM;	scriptaddr = (void *)local_to_PCI((u_long)script);	cmd = ALLOC(struct scsipi_generic, SIOP_SCSI_COMMAND_SIZE);	if (cmd == NULL)		return ENOMEM;	sense = ALLOC(struct scsi_request_sense, SIOP_SCSI_COMMAND_SIZE);	if (sense == NULL)		return ENOMEM;	data = ALLOC(u_char, SIOP_SCSI_DATA_SIZE);	if (data == NULL)		return ENOMEM;	xfer = ALLOC(struct siop_xfer, sizeof(struct siop_xfer));	if (xfer == NULL)		return ENOMEM;	siop_xfer_setup(xfer, scriptaddr);	id = readb(addr + SIOP_SCID) & SCID_ENCID_MASK;	/* reset bus */	reg = readb(addr + SIOP_SCNTL1);	writeb(addr + SIOP_SCNTL1, reg | SCNTL1_RST);	delay(100);	writeb(addr + SIOP_SCNTL1, reg);	/* reset the chip */	writeb(addr + SIOP_ISTAT, ISTAT_SRST);	delay(1000);	writeb(addr + SIOP_ISTAT, 0);	/* init registers */	writeb(addr + SIOP_SCNTL0, SCNTL0_ARB_MASK | SCNTL0_EPC | SCNTL0_AAP);	writeb(addr + SIOP_SCNTL1, 0);	writeb(addr + SIOP_SCNTL3, clock_div);	writeb(addr + SIOP_SXFER, 0);	writeb(addr + SIOP_DIEN, 0xff);	writeb(addr + SIOP_SIEN0, 0xff & ~(SIEN0_CMP | SIEN0_SEL | SIEN0_RSL));	writeb(addr + SIOP_SIEN1, 0xff & ~(SIEN1_HTH | SIEN1_GEN));	writeb(addr + SIOP_STEST2, 0);	writeb(addr + SIOP_STEST3, STEST3_TE);	writeb(addr + SIOP_STIME0, (0xb << STIME0_SEL_SHIFT));	writeb(addr + SIOP_SCID, id | SCID_RRE);	writeb(addr + SIOP_RESPID0, 1 << id);	writeb(addr + SIOP_DCNTL, DCNTL_COM);	/* BeBox uses PCIC */	writeb(addr + SIOP_STEST1, STEST1_SCLK);	siop_pci_reset(addr);	/* copy and patch the script */	for (i = 0; i < __arraycount(siop_script); i++)		script[i] = htoc32(siop_script[i]);	for (i = 0; i < __arraycount(E_abs_msgin_Used); i++)		script[E_abs_msgin_Used[i]] =		    htoc32(scriptaddr + Ent_msgin_space);	/* start script */	_wbinv((u_long)script, SIOP_SCRIPT_SIZE);	writel(addr + SIOP_DSP, (int)scriptaddr + Ent_reselect);	memset(&tmp, 0, sizeof(tmp));	tmp.id = id;	tmp.clock_div = clock_div;	tmp.addr = addr;	tmp.script = script;	tmp.xfer = xfer;	tmp.cmd = cmd;	tmp.sense = sense;	tmp.data = data;	tmp.currschedslot = 0;	tmp.sel_t = -1;//.........这里部分代码省略.........
开发者ID:krytarowski,项目名称:netbsd-current-src-sys,代码行数:101,


示例27: hx509_cms_envelope_1

inthx509_cms_envelope_1(hx509_context context,		     int flags,		     hx509_cert cert,		     const void *data,		     size_t length,		     const heim_oid *encryption_type,		     const heim_oid *contentType,		     heim_octet_string *content){    KeyTransRecipientInfo *ri;    heim_octet_string ivec;    heim_octet_string key;    hx509_crypto crypto = NULL;    EnvelopedData ed;    size_t size;    int ret;    memset(&ivec, 0, sizeof(ivec));    memset(&key, 0, sizeof(key));    memset(&ed, 0, sizeof(ed));    memset(content, 0, sizeof(*content));    if (encryption_type == NULL)	encryption_type = &asn1_oid_id_aes_256_cbc;    if ((flags & HX509_CMS_EV_NO_KU_CHECK) == 0) {	ret = _hx509_check_key_usage(context, cert, 1 << 2, TRUE);	if (ret)	    goto out;    }    ret = hx509_crypto_init(context, NULL, encryption_type, &crypto);    if (ret)	goto out;    if (flags & HX509_CMS_EV_ALLOW_WEAK)	hx509_crypto_allow_weak(crypto);    ret = hx509_crypto_set_random_key(crypto, &key);    if (ret) {	hx509_set_error_string(context, 0, ret,			       "Create random key for EnvelopedData content");	goto out;    }    ret = hx509_crypto_random_iv(crypto, &ivec);    if (ret) {	hx509_set_error_string(context, 0, ret,			       "Failed to create a random iv");	goto out;    }    ret = hx509_crypto_encrypt(crypto,			       data,			       length,			       &ivec,			       &ed.encryptedContentInfo.encryptedContent);    if (ret) {	hx509_set_error_string(context, 0, ret,			       "Failed to encrypt EnvelopedData content");	goto out;    }    {	AlgorithmIdentifier *enc_alg;	enc_alg = &ed.encryptedContentInfo.contentEncryptionAlgorithm;	ret = der_copy_oid(encryption_type, &enc_alg->algorithm);	if (ret) {	    hx509_set_error_string(context, 0, ret,				   "Failed to set crypto oid "				   "for EnvelopedData");	    goto out;	}		ALLOC(enc_alg->parameters, 1);	if (enc_alg->parameters == NULL) {	    ret = ENOMEM;	    hx509_set_error_string(context, 0, ret,				   "Failed to allocate crypto paramaters "				   "for EnvelopedData");	    goto out;	}	ret = hx509_crypto_get_params(context,				      crypto,				      &ivec,				      enc_alg->parameters);	if (ret) {	    goto out;	}    }    ALLOC_SEQ(&ed.recipientInfos, 1);    if (ed.recipientInfos.val == NULL) {	ret = ENOMEM;	hx509_set_error_string(context, 0, ret,			       "Failed to allocate recipients info "			       "for EnvelopedData");	goto out;    }//.........这里部分代码省略.........
开发者ID:0x24bin,项目名称:winexe-1,代码行数:101,


示例28: d_alloc_call_out

/* * NAME:	data->alloc_call_out() * DESCRIPTION:	allocate a new callout */static uindex d_alloc_call_out(dataspace *data, uindex handle, Uint time, 	unsigned short mtime, int nargs, value *v){    dcallout *co;    if (data->ncallouts == 0) {	/*	 * the first in this object	 */	co = data->callouts = ALLOC(dcallout, 1);	data->ncallouts = handle = 1;	data->plane->flags |= MOD_NEWCALLOUT;    } else {	if (data->callouts == (dcallout *) NULL) {	    d_get_callouts(data);	}	if (handle != 0) {	    /*	     * get a specific callout from the free list	     */	    co = &data->callouts[handle - 1];	    if (handle == data->fcallouts) {		data->fcallouts = co->co_next;	    } else {		data->callouts[co->co_prev - 1].co_next = co->co_next;		if (co->co_next != 0) {		    data->callouts[co->co_next - 1].co_prev = co->co_prev;		}	    }	} else {	    handle = data->fcallouts;	    if (handle != 0) {		/*		 * from free list		 */		co = &data->callouts[handle - 1];		if (co->co_next == 0 || co->co_next > handle) {		    /* take 1st free callout */		    data->fcallouts = co->co_next;		} else {		    /* take 2nd free callout */		    co = &data->callouts[co->co_next - 1];		    data->callouts[handle - 1].co_next = co->co_next;		    if (co->co_next != 0) {			data->callouts[co->co_next - 1].co_prev = handle;		    }		    handle = co - data->callouts + 1;		}		data->plane->flags |= MOD_CALLOUT;	    } else {		/*		 * add new callout		 */		handle = data->ncallouts;		co = data->callouts = REALLOC(data->callouts, dcallout, handle,					      handle + 1);		co += handle;		data->ncallouts = ++handle;		data->plane->flags |= MOD_NEWCALLOUT;	    }	}    }    co->time = time;    co->mtime = mtime;    co->nargs = nargs;    memcpy(co->val, v, sizeof(co->val));    switch (nargs) {    default:	ref_rhs(data, &v[3]);    case 2:	ref_rhs(data, &v[2]);    case 1:	ref_rhs(data, &v[1]);    case 0:	ref_rhs(data, &v[0]);	break;    }    return handle;}
开发者ID:Miraculix,项目名称:dgd,代码行数:85,


示例29: unzlocal_SearchCentralDir

static DWORD unzlocal_SearchCentralDir(const zlib_filefunc_def *pzlib_filefunc_def, void *filestream){  BYTE *buf;  DWORD uSizeFile;  DWORD uBackRead;  DWORD uMaxBack = 0xffff; /* maximum size of global comment */  DWORD uPosFound = 0;  if (ZSEEK(*pzlib_filefunc_def, filestream, 0, SEEK_END) != 0)  {    return 0;  }  uSizeFile = ZTELL(*pzlib_filefunc_def, filestream);  if (uMaxBack > uSizeFile)  {    uMaxBack = uSizeFile;  }  buf = (BYTE*)ALLOC(BUFREADCOMMENT + 4);  if (buf == NULL)  {    return 0;  }  uBackRead = 4;  while (uBackRead < uMaxBack)  {    DWORD uReadSize, uReadPos;    int i;    if (uBackRead + BUFREADCOMMENT > uMaxBack)    {      uBackRead = uMaxBack;    }    else    {      uBackRead += BUFREADCOMMENT;    }    uReadPos = uSizeFile - uBackRead;    uReadSize = ((BUFREADCOMMENT + 4) < (uSizeFile - uReadPos)) ? (BUFREADCOMMENT + 4): (uSizeFile - uReadPos);    if (ZSEEK(*pzlib_filefunc_def, filestream, uReadPos, SEEK_SET) != 0)    {      break;    }    if (ZREAD(*pzlib_filefunc_def, filestream, buf, uReadSize) != uReadSize)    {      break;    }    for (i = (int)uReadSize - 3; (i--) > 0;)    if (((*(buf + i)) == 0x50) && ((*(buf + i + 1)) == 0x4b) && ((*(buf + i + 2)) == 0x05) && ((*(buf + i + 3)) == 0x06))    {      uPosFound = uReadPos + i;      break;    }    if (uPosFound != 0)    {      break;    }  }  TRYFREE(buf);  return uPosFound;}
开发者ID:Doodle-Jump,项目名称:PC,代码行数:68,



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


C++ ALLOCA函数代码示例
C++ ALLEGRO_WARN函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。