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

C++ ALLOC_ARRAY函数代码示例

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

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



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

示例1: FT_EXPORT_DEF

  FT_EXPORT_DEF( FT_Error )  FT_Outline_New_Internal(
                               FT_Memory    memory,
                               FT_UInt      numPoints,
                               FT_Int       numContours,
                               FT_Outline  *anoutline )
  {
    FT_Error  error;


    if ( !anoutline || !memory )
      return FT_Err_Invalid_Argument;

    *anoutline = null_outline;

    if ( ALLOC_ARRAY( anoutline->points,   numPoints * 2L, FT_Pos    ) ||
         ALLOC_ARRAY( anoutline->tags,     numPoints,      FT_Byte   ) ||
         ALLOC_ARRAY( anoutline->contours, numContours,    FT_UShort ) )
      goto Fail;

    anoutline->n_points    = (FT_UShort)numPoints;
    anoutline->n_contours  = (FT_Short)numContours;
    anoutline->flags      |= ft_outline_owner;

    return FT_Err_Ok;

  Fail:
    anoutline->flags |= ft_outline_owner;
    FT_Outline_Done_Internal( memory, anoutline );

    return error;
  }
开发者ID:opieproject,项目名称:qte-opie,代码行数:31,代码来源:ftoutln.c


示例2: TT_New_GlyphZone

LOCAL_FUNC
FT_Error TT_New_GlyphZone(FT_Memory memory,
                          FT_UShort maxPoints,
                          FT_Short maxContours,
                          TT_GlyphZone  *zone)
{
	FT_Error error;


	if(maxPoints > 0)
	{
		maxPoints += 2;
	}

	MEM_Set(zone, 0, sizeof(*zone));
	zone->memory = memory;

	if(ALLOC_ARRAY(zone->org,      maxPoints * 2, FT_F26Dot6) ||
	        ALLOC_ARRAY(zone->cur,      maxPoints * 2, FT_F26Dot6) ||
	        ALLOC_ARRAY(zone->tags,     maxPoints,     FT_Byte) ||
	        ALLOC_ARRAY(zone->contours, maxContours,   FT_UShort))
	{
		TT_Done_GlyphZone(zone);
	}

	return error;
}
开发者ID:Diskutant,项目名称:RTCW-SP,代码行数:27,代码来源:ttobjs.c


示例3: Instance_Create

  TT_Error  Instance_Create( void*  _instance,
                             void*  _face )
  {
    PInstance ins  = (PInstance)_instance;
    PFace     face = (PFace)_face;
    ttfMemory *mem = face->font->tti->ttf_memory;
    PMaxProfile  maxp = &face->maxProfile;
    Int       i;

    ins->FDefs=NULL;
    ins->IDefs=NULL;
    ins->cvt=NULL;
    ins->storage=NULL;

    ins->face = face;
    ins->valid = FALSE;

    ins->numFDefs = maxp->maxFunctionDefs;
    ins->numIDefs = maxp->maxInstructionDefs;
    ins->countIDefs = 0;
    if (maxp->maxInstructionDefs > 255)
	maxp->maxInstructionDefs = 255;  /* Bug 689960 */
    memset(ins->IDefPtr, (Byte)ins->numIDefs, sizeof(ins->IDefPtr));
    if (ins->numFDefs < 50)
	ins->numFDefs = 50; /* Bug 687858 */
    ins->cvtSize  = face->cvtSize;

    ins->metrics.pointSize    = 10 * 64;     /* default pointsize  = 10pts */

    ins->metrics.x_resolution = 96;          /* default resolution = 96dpi */
    ins->metrics.y_resolution = 96;

    ins->metrics.x_ppem = 0;
    ins->metrics.y_ppem = 0;

    ins->metrics.rotated   = FALSE;
    ins->metrics.stretched = FALSE;

    ins->storeSize = maxp->maxStorage;

    for ( i = 0; i < 4; i++ )
      ins->metrics.compensations[i] = 0;     /* Default compensations */

    if ( ALLOC_ARRAY( ins->FDefs, 0, ins->numFDefs, TDefRecord )  ||
         ALLOC_ARRAY( ins->IDefs, 0, ins->numIDefs, TDefRecord )  ||
         ALLOC_ARRAY( ins->cvt, 0, ins->cvtSize, Long )           ||
         ALLOC_ARRAY( ins->storage, 0, ins->storeSize, Long )     )
      goto Fail_Memory;

    memset (ins->FDefs, 0, ins->numFDefs * sizeof(TDefRecord));
    memset (ins->IDefs, 0, ins->numIDefs * sizeof(TDefRecord));

    ins->GS = Default_GraphicsState;

    return TT_Err_Ok;

  Fail_Memory:
    Instance_Destroy( ins );
    return TT_Err_Out_Of_Memory;
  }
开发者ID:ststeiger,项目名称:ghostsvg,代码行数:60,代码来源:ttobjs.c


示例4: get_correspondences

static void get_correspondences(struct string_list *a, struct string_list *b,
				int creation_factor)
{
	int n = a->nr + b->nr;
	int *cost, c, *a2b, *b2a;
	int i, j;

	ALLOC_ARRAY(cost, st_mult(n, n));
	ALLOC_ARRAY(a2b, n);
	ALLOC_ARRAY(b2a, n);

	for (i = 0; i < a->nr; i++) {
		struct patch_util *a_util = a->items[i].util;

		for (j = 0; j < b->nr; j++) {
			struct patch_util *b_util = b->items[j].util;

			if (a_util->matching == j)
				c = 0;
			else if (a_util->matching < 0 && b_util->matching < 0)
				c = diffsize(a_util->diff, b_util->diff);
			else
				c = COST_MAX;
			cost[i + n * j] = c;
		}

		c = a_util->matching < 0 ?
			a_util->diffsize * creation_factor / 100 : COST_MAX;
		for (j = b->nr; j < n; j++)
			cost[i + n * j] = c;
	}

	for (j = 0; j < b->nr; j++) {
		struct patch_util *util = b->items[j].util;

		c = util->matching < 0 ?
			util->diffsize * creation_factor / 100 : COST_MAX;
		for (i = a->nr; i < n; i++)
			cost[i + n * j] = c;
	}

	for (i = a->nr; i < n; i++)
		for (j = b->nr; j < n; j++)
			cost[i + n * j] = 0;

	compute_assignment(n, n, cost, a2b, b2a);

	for (i = 0; i < a->nr; i++)
		if (a2b[i] >= 0 && a2b[i] < b->nr) {
			struct patch_util *a_util = a->items[i].util;
			struct patch_util *b_util = b->items[a2b[i]].util;

			a_util->matching = a2b[i];
			b_util->matching = i;
		}

	free(cost);
	free(a2b);
	free(b2a);
}
开发者ID:Nowher2,项目名称:git,代码行数:60,代码来源:range-diff.c


示例5: sumAndProduct

G_MODULE_EXPORT const XLOPER* sumAndProduct(const XLOPER*m){
	XLOPER*r=NULL;
	if ( NULL!=m ) {
		r=ALLOC_ARRAY(XLOPER,1);
		r->xltype=xltypeMulti|xlbitDLLFree;
		r->val.array.rows=1;
		r->val.array.columns=2;
		r->val.array.lparray=ALLOC_ARRAY(XLOPER,2);
		r->val.array.lparray[0].xltype=xltypeNum;
		r->val.array.lparray[0].val.num = 0;
		r->val.array.lparray[1].xltype=xltypeNum;
		r->val.array.lparray[1].val.num = 1;
		if ((m->xltype&xltypeType)==xltypeMulti){
			int i,j;
			for (i=0;i<m->val.array.columns;++i){
				for (j=0;j<m->val.array.rows;++j){
					const double x = m->val.array.lparray[i*m->val.array.rows+j].val.num;
					r->val.array.lparray[0].val.num += x;
					r->val.array.lparray[1].val.num *= x;
				}
			}
		}

	}
	return r;
}
开发者ID:arcean,项目名称:gnumeric-for-maemo-5,代码行数:26,代码来源:ExcelTestModule.c


示例6: xmalloc

struct git_graph *graph_init(struct rev_info *opt)
{
	struct git_graph *graph = xmalloc(sizeof(struct git_graph));

	if (!column_colors) {
		char *string;
		if (git_config_get_string("log.graphcolors", &string)) {
			/* not configured -- use default */
			graph_set_column_colors(column_colors_ansi,
						column_colors_ansi_max);
		} else {
			static struct argv_array custom_colors = ARGV_ARRAY_INIT;
			argv_array_clear(&custom_colors);
			parse_graph_colors_config(&custom_colors, string);
			free(string);
			/* graph_set_column_colors takes a max-index, not a count */
			graph_set_column_colors(custom_colors.argv,
						custom_colors.argc - 1);
		}
	}

	graph->commit = NULL;
	graph->revs = opt;
	graph->num_parents = 0;
	graph->expansion_row = 0;
	graph->state = GRAPH_PADDING;
	graph->prev_state = GRAPH_PADDING;
	graph->commit_index = 0;
	graph->prev_commit_index = 0;
	graph->num_columns = 0;
	graph->num_new_columns = 0;
	graph->mapping_size = 0;
	/*
	 * Start the column color at the maximum value, since we'll
	 * always increment it for the first commit we output.
	 * This way we start at 0 for the first commit.
	 */
	graph->default_column_color = column_colors_max - 1;

	/*
	 * Allocate a reasonably large default number of columns
	 * We'll automatically grow columns later if we need more room.
	 */
	graph->column_capacity = 30;
	ALLOC_ARRAY(graph->columns, graph->column_capacity);
	ALLOC_ARRAY(graph->new_columns, graph->column_capacity);
	ALLOC_ARRAY(graph->mapping, 2 * graph->column_capacity);
	ALLOC_ARRAY(graph->new_mapping, 2 * graph->column_capacity);

	/*
	 * The diff output prefix callback, with this we can make
	 * all the diff output to align with the graph lines.
	 */
	opt->diffopt.output_prefix = diff_output_prefix_callback;
	opt->diffopt.output_prefix_data = graph;

	return graph;
}
开发者ID:KarthikNayak,项目名称:git,代码行数:58,代码来源:graph.c


示例7: xdiff_set_find_func

void xdiff_set_find_func(xdemitconf_t *xecfg, const char *value, int cflags)
{
	int i;
	struct ff_regs *regs;

	xecfg->find_func = ff_regexp;
	regs = xecfg->find_func_priv = xmalloc(sizeof(struct ff_regs));
	for (i = 0, regs->nr = 1; value[i]; i++)
		if (value[i] == '\n')
			regs->nr++;
	ALLOC_ARRAY(regs->array, regs->nr);
	for (i = 0; i < regs->nr; i++) {
		struct ff_reg *reg = regs->array + i;
		const char *ep = strchr(value, '\n'), *expression;
		char *buffer = NULL;

		reg->negate = (*value == '!');
		if (reg->negate && i == regs->nr - 1)
			die("Last expression must not be negated: %s", value);
		if (*value == '!')
			value++;
		if (ep)
			expression = buffer = xstrndup(value, ep - value);
		else
			expression = value;
		if (regcomp(&reg->re, expression, cflags))
			die("Invalid regexp to look for hunk header: %s", expression);
		free(buffer);
		value = ep + 1;
	}
}
开发者ID:chidveer,项目名称:git,代码行数:31,代码来源:xdiff-interface.c


示例8: ALLOC_ARRAY

*/	void Init_Ports(void)
/*
**		Initialize port scheme related subsystems.
**
**	In order to add a port scheme:
**
**		In mezz-ports.r add a make-scheme.
**		Add an Init_*_Scheme() here.
**		Be sure host-devices.c has the device enabled.
**
***********************************************************************/
{
	Scheme_Actions = ALLOC_ARRAY(SCHEME_ACTIONS, MAX_SCHEMES);
	CLEAR(Scheme_Actions, MAX_SCHEMES * sizeof(SCHEME_ACTIONS));

	Init_Console_Scheme();
	Init_File_Scheme();
	Init_Dir_Scheme();
	Init_Event_Scheme();
	Init_TCP_Scheme();
	Init_UDP_Scheme();
	Init_DNS_Scheme();

#ifdef TO_WINDOWS
	Init_Clipboard_Scheme();
#endif

#if defined(TO_LINUX) || defined(TO_WINDOWS)
	Init_Serial_Scheme();
#endif

#ifdef HAS_POSIX_SIGNAL
	Init_Signal_Scheme();
#endif
}
开发者ID:kealist,项目名称:ren-c,代码行数:35,代码来源:c-port.c


示例9: arrangeInSquareMatrix

G_MODULE_EXPORT const XLOPER* arrangeInSquareMatrix(const XLOPER*a,const XLOPER*b,const XLOPER*c,const XLOPER*d){
	XLOPER*r=NULL;
	if ( NULL!=a && NULL!=b && NULL!=c && NULL!=d ) {
		r=ALLOC_ARRAY(XLOPER,1);
		r->xltype=xltypeMulti|xlbitDLLFree;
		r->val.array.rows=2;
		r->val.array.columns=2;
		r->val.array.lparray=ALLOC_ARRAY(XLOPER,4);
		copy_construct_xloper(r->val.array.lparray  ,a);
		copy_construct_xloper(r->val.array.lparray+1,b);
		copy_construct_xloper(r->val.array.lparray+2,c);
		copy_construct_xloper(r->val.array.lparray+3,d);

	}
	return r;
}
开发者ID:arcean,项目名称:gnumeric-for-maemo-5,代码行数:16,代码来源:ExcelTestModule.c


示例10: transport_fetch_refs

int transport_fetch_refs(struct transport *transport, struct ref *refs)
{
	int rc;
	int nr_heads = 0, nr_alloc = 0, nr_refs = 0;
	struct ref **heads = NULL;
	struct ref *rm;

	for (rm = refs; rm; rm = rm->next) {
		nr_refs++;
		if (rm->peer_ref &&
		    !is_null_oid(&rm->old_oid) &&
		    !oidcmp(&rm->peer_ref->old_oid, &rm->old_oid))
			continue;
		ALLOC_GROW(heads, nr_heads + 1, nr_alloc);
		heads[nr_heads++] = rm;
	}

	if (!nr_heads) {
		/*
		 * When deepening of a shallow repository is requested,
		 * then local and remote refs are likely to still be equal.
		 * Just feed them all to the fetch method in that case.
		 * This condition shouldn't be met in a non-deepening fetch
		 * (see builtin/fetch.c:quickfetch()).
		 */
		ALLOC_ARRAY(heads, nr_refs);
		for (rm = refs; rm; rm = rm->next)
			heads[nr_heads++] = rm;
	}

	rc = transport->fetch(transport, nr_heads, heads);

	free(heads);
	return rc;
}
开发者ID:KarthikNayak,项目名称:git,代码行数:35,代码来源:transport.c


示例11: fetch_dumb

static int fetch_dumb(int nr_heads, struct ref **to_fetch)
{
	struct walker *walker;
	char **targets;
	int ret, i;

	ALLOC_ARRAY(targets, nr_heads);
	if (options.depth)
		die("dumb http transport does not support --depth");
	for (i = 0; i < nr_heads; i++)
		targets[i] = xstrdup(oid_to_hex(&to_fetch[i]->old_oid));

	walker = get_http_walker(url.buf);
	walker->get_all = 1;
	walker->get_tree = 1;
	walker->get_history = 1;
	walker->get_verbosely = options.verbosity >= 3;
	walker->get_recover = 0;
	ret = walker_fetch(walker, nr_heads, targets, NULL, NULL);
	walker_free(walker);

	for (i = 0; i < nr_heads; i++)
		free(targets[i]);
	free(targets);

	return ret ? error("fetch failed.") : 0;
}
开发者ID:136357477,项目名称:git,代码行数:27,代码来源:remote-curl.c


示例12: P1

/*
 * Allocate an array of size 'n'.
 */
array_t *allocate_array P1(int, n)
{
    array_t *p;

    if (n < 0 || n > max_array_size)
	error("Illegal array size.\n");
    if (n == 0) {
	return null_array();
    }
    num_arrays++;
    total_array_size += sizeof(array_t) + sizeof(svalue_t) *
	(n - 1);
    p = ALLOC_ARRAY(n);
    p->ref = 1;
    p->size = n;
#ifdef PACKAGE_MUDLIB_STATS
    if (current_object) {
	assign_stats(&p->stats, current_object);
	add_array_size(&p->stats, n);
    } else {
	null_stats(&p->stats);
    }
#endif
    while (n--)
	p->item[n] = const0;
    return p;
}
开发者ID:quixadhal,项目名称:discworld,代码行数:30,代码来源:array.c


示例13: display_table

/* Display COL_COLUMN or COL_ROW */
static void display_table(const struct string_list *list,
			  unsigned int colopts,
			  const struct column_options *opts)
{
	struct column_data data;
	int x, y, i, initial_width;
	char *empty_cell;

	memset(&data, 0, sizeof(data));
	data.list = list;
	data.colopts = colopts;
	data.opts = *opts;

	ALLOC_ARRAY(data.len, list->nr);
	for (i = 0; i < list->nr; i++)
		data.len[i] = item_length(colopts, list->items[i].string);

	layout(&data, &initial_width);

	if (colopts & COL_DENSE)
		shrink_columns(&data);

	empty_cell = xmallocz(initial_width);
	memset(empty_cell, ' ', initial_width);
	for (y = 0; y < data.rows; y++) {
		for (x = 0; x < data.cols; x++)
			if (display_cell(&data, initial_width, empty_cell, x, y))
				break;
	}

	free(data.len);
	free(data.width);
	free(empty_cell);
}
开发者ID:MichaelBlume,项目名称:git,代码行数:35,代码来源:column.c


示例14: Subtable_Load_0

  static TT_Error
  Subtable_Load_0( TT_Kern_0*  kern0,
                   PFace       input )
  {
    DEFINE_LOAD_LOCALS( input->stream );

    UShort  num_pairs, n;


    if ( ACCESS_Frame( 8L ) )
      return error;

    num_pairs            = GET_UShort();
    kern0->nPairs        = 0;
    kern0->searchRange   = GET_UShort();
    kern0->entrySelector = GET_UShort();
    kern0->rangeShift    = GET_UShort();

    /* we only set kern0->nPairs if the subtable has been loaded */

    FORGET_Frame();

    if ( ALLOC_ARRAY( kern0->pairs, num_pairs, TT_Kern_0_Pair ) )
      return error;

    if ( ACCESS_Frame( num_pairs * 6L ) )
      goto Fail;

    for ( n = 0; n < num_pairs; n++ )
    {
      kern0->pairs[n].left  = GET_UShort();
      kern0->pairs[n].right = GET_UShort();
      kern0->pairs[n].value = GET_UShort();

      if ( kern0->pairs[n].left >= input->numGlyphs ||
           kern0->pairs[n].right >= input->numGlyphs )
      {
        FORGET_Frame();
        error = TT_Err_Invalid_Kerning_Table;
        goto Fail;
      }
    }

    FORGET_Frame();

    /* we're ok, set the pairs count */
    kern0->nPairs = num_pairs;

    /* the spec says that the kerning pairs must be sorted,
       but some brain damaged font producers don't do that correctly.. (JvR 3/4/2000) */
    if ( !is_sorted( kern0->pairs, num_pairs ) )
      sort_kern_pairs( kern0->pairs, num_pairs );

    return TT_Err_Ok;

    Fail:
      FREE( kern0->pairs );
      return error;
  }
开发者ID:bngabonziza,项目名称:miktex,代码行数:59,代码来源:ftxkern.c


示例15: xmalloc

struct git_graph *graph_init(struct rev_info *opt)
{
	struct git_graph *graph = xmalloc(sizeof(struct git_graph));

	if (!column_colors)
		graph_set_column_colors(column_colors_ansi,
					column_colors_ansi_max);

	graph->commit = NULL;
	graph->revs = opt;
	graph->num_parents = 0;
	graph->expansion_row = 0;
	graph->state = GRAPH_PADDING;
	graph->prev_state = GRAPH_PADDING;
	graph->commit_index = 0;
	graph->prev_commit_index = 0;
	graph->num_columns = 0;
	graph->num_new_columns = 0;
	graph->mapping_size = 0;
	/*
	 * Start the column color at the maximum value, since we'll
	 * always increment it for the first commit we output.
	 * This way we start at 0 for the first commit.
	 */
	graph->default_column_color = column_colors_max - 1;

	/*
	 * Allocate a reasonably large default number of columns
	 * We'll automatically grow columns later if we need more room.
	 */
	graph->column_capacity = 30;
	ALLOC_ARRAY(graph->columns, graph->column_capacity);
	ALLOC_ARRAY(graph->new_columns, graph->column_capacity);
	ALLOC_ARRAY(graph->mapping, 2 * graph->column_capacity);
	ALLOC_ARRAY(graph->new_mapping, 2 * graph->column_capacity);

	/*
	 * The diff output prefix callback, with this we can make
	 * all the diff output to align with the graph lines.
	 */
	opt->diffopt.output_prefix = diff_output_prefix_callback;
	opt->diffopt.output_prefix_data = graph;
	opt->diffopt.output_prefix_length = 0;

	return graph;
}
开发者ID:1tgr,项目名称:git,代码行数:46,代码来源:graph.c


示例16: FT_EXPORT_DEF

  FT_EXPORT_DEF( FT_Error )  FTC_ChunkSet_New( FTC_Chunk_Cache  cache,
                                               FT_Pointer       type,
                                               FTC_ChunkSet    *aset )
  {
    FT_Error      error;
    FT_Memory     memory  = cache->root.memory;
    FTC_Manager   manager = cache->root.manager;
    FTC_ChunkSet  cset    = 0;

    FTC_Chunk_Cache_Class*  ccache_class;
    FTC_ChunkSet_Class*     clazz;


    ccache_class = (FTC_Chunk_Cache_Class*)cache->root.clazz;
    clazz        = ccache_class->cset_class;

    *aset = 0;

    if ( ALLOC( cset, clazz->cset_byte_size ) )
      goto Exit;

    cset->cache   = cache;
    cset->manager = manager;
    cset->memory  = memory;
    cset->clazz   = clazz;

    /* now compute element_max, element_count and element_size */
    error = clazz->sizes( cset, type );
    if ( error )
      goto Exit;

    /* compute maximum number of nodes */
    cset->num_chunks = ( cset->element_max + cset->element_count - 1 ) /
                       cset->element_count;

    /* allocate chunk pointers table */
    if ( ALLOC_ARRAY( cset->chunks, cset->num_chunks, FTC_ChunkNode ) )
      goto Exit;

    /* initialize set by type if needed */
    if ( clazz->init )
    {
      error = clazz->init( cset, type );
      if ( error )
        goto Exit;
    }

    *aset = cset;

  Exit:
    if ( error && cset )
    {
      FREE( cset->chunks );
      FREE( cset );
    }

    return error;
  }
开发者ID:Joincheng,项目名称:lithtech,代码行数:58,代码来源:ftcchunk.c


示例17: convertAstronomicalUnitsToKilometers

G_MODULE_EXPORT const XLOPER* convertAstronomicalUnitsToKilometers(const XLOPER*x){
	XLOPER*r=NULL;
	if ( NULL!=x && (x->xltype&xltypeType)==xltypeNum ) {
		r=ALLOC_ARRAY(XLOPER,1);
		r->xltype=xltypeNum|xlbitDLLFree;
		r->val.num=x->val.num*149600000.;
	}
	return r;
}
开发者ID:arcean,项目名称:gnumeric-for-maemo-5,代码行数:9,代码来源:ExcelTestModule.c


示例18: multiplyTwoNumbers

G_MODULE_EXPORT const XLOPER* multiplyTwoNumbers(const XLOPER*x,const XLOPER*y){
	XLOPER*r=NULL;
	if ( NULL!=x && (x->xltype&xltypeType)==xltypeNum && NULL!=y && (y->xltype&xltypeType)==xltypeNum ) {
		r=ALLOC_ARRAY(XLOPER,1);
		r->xltype=xltypeNum|xlbitDLLFree;
		r->val.num=x->val.num*y->val.num;
	}
	return r;
}
开发者ID:arcean,项目名称:gnumeric-for-maemo-5,代码行数:9,代码来源:ExcelTestModule.c


示例19: bitmap_writer_build_type_index

/**
 * Build the initial type index for the packfile
 */
void bitmap_writer_build_type_index(struct packing_data *to_pack,
				    struct pack_idx_entry **index,
				    uint32_t index_nr)
{
	uint32_t i;

	writer.commits = ewah_new();
	writer.trees = ewah_new();
	writer.blobs = ewah_new();
	writer.tags = ewah_new();
	ALLOC_ARRAY(to_pack->in_pack_pos, to_pack->nr_objects);

	for (i = 0; i < index_nr; ++i) {
		struct object_entry *entry = (struct object_entry *)index[i];
		enum object_type real_type;

		oe_set_in_pack_pos(to_pack, entry, i);

		switch (oe_type(entry)) {
		case OBJ_COMMIT:
		case OBJ_TREE:
		case OBJ_BLOB:
		case OBJ_TAG:
			real_type = oe_type(entry);
			break;

		default:
			real_type = oid_object_info(to_pack->repo,
						    &entry->idx.oid, NULL);
			break;
		}

		switch (real_type) {
		case OBJ_COMMIT:
			ewah_set(writer.commits, i);
			break;

		case OBJ_TREE:
			ewah_set(writer.trees, i);
			break;

		case OBJ_BLOB:
			ewah_set(writer.blobs, i);
			break;

		case OBJ_TAG:
			ewah_set(writer.tags, i);
			break;

		default:
			die("Missing type information for %s (%d/%d)",
			    oid_to_hex(&entry->idx.oid), real_type,
			    oe_type(entry));
		}
	}
}
开发者ID:PKRoma,项目名称:git,代码行数:59,代码来源:pack-bitmap-write.c


示例20: NETSpeedTest

void NETSpeedTest(uint iterations, uint inputLength, uint layersCount, uint neuronsCountInEachLayer, ActivationFunctionPtr actFunction)
{
		uint* layersParams;
		uint i;
		double* inputVector;
		MultilayerNET* NET;
		StopWatch stopWatch;
		TimeInterval timeInterval;

		inputVector = ALLOC_ARRAY(double, inputLength);
		for(i = 0; i < inputLength; i++)
		{
			inputVector[i] = i;
		}

		layersParams = ALLOC_ARRAY(uint, layersCount);
		for(i = 0; i < layersCount; i++)
		{
			layersParams[i] = neuronsCountInEachLayer;
		}

		NET = CreateNewMultilayerNET(layersCount, inputLength, actFunction, layersParams);

		if(NET == NULL)
		{
			printf("ERROR\n");
			return;
		}

		Reset(&stopWatch);
		Start(&stopWatch);

		for(i = 0; i < iterations; i++)
		{
			ComputeNETOutput(NET, inputVector, inputLength);
		}

		Stop(&stopWatch);
		CalcElapsedMilliSeconds(&stopWatch);
		ToTimeIntervalStruct(&stopWatch, &timeInterval);

		printf("NET SPEED TEST:\nPARAMETRS:\n iterations: %d\n input length: %d\n layers's count: %d\n Count of neurons in each layer: %d\n",
			iterations, inputLength, layersCount, neuronsCountInEachLayer);
		printf("ELAPSED TIME:\n");
		printf(" milliseconds: %d\n", timeInterval.Miliseconds);
		printf(" seconds: %d\n", timeInterval.Seconds);
		printf(" minets: %d\n", timeInterval.Minets);
		printf(" hours: %d\n", timeInterval.Hours);
		printf("\n");

		free(layersParams);
		free(inputVector);
		DisposeNET(NET);
}
开发者ID:NekitkoL,项目名称:BackpropagationLearningAlgoritm,代码行数:54,代码来源:SpeedTests.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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