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

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

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

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

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

示例1: offset

/*!   /brief Add new line to updated   /param Plus pointer to Plus_head structure   /param line line id   /param offset line offset (negative offset is ignored) */void dig_line_add_updated(struct Plus_head *Plus, int line){    int i;        G_debug(3, "dig_line_add_updated(): line = %d", line);    /* Check if already in list */    for (i = 0; i < Plus->uplist.n_uplines; i++) {	if (Plus->uplist.uplines[i] == line) {            G_debug(3, "/tskipped");	    return;        }    }        /* Alloc space if needed */    if (Plus->uplist.n_uplines == Plus->uplist.alloc_uplines) {	Plus->uplist.alloc_uplines += 1000;	Plus->uplist.uplines =	    (int *)G_realloc(Plus->uplist.uplines,			     Plus->uplist.alloc_uplines * sizeof(int));	Plus->uplist.uplines_offset =	    (off_t *)G_realloc(Plus->uplist.uplines_offset,			     Plus->uplist.alloc_uplines * sizeof(off_t));    }    Plus->uplist.uplines[Plus->uplist.n_uplines] = line;    Plus->uplist.n_uplines++;}
开发者ID:caomw,项目名称:grass,代码行数:35,


示例2: offset

/*!   /brief Add new line to updated   /param Plus pointer to Plus_head structure   /param line line id   /param offset line offset (negative offset is ignored) */void dig_line_add_updated(struct Plus_head *Plus, int line, off_t offset){    int i;        G_debug(3, "dig_line_add_updated(): line = %d", line);    /* undo/redo in the digitizer needs all steps,      * disable check */#if 0    /* Check if already in list */    for (i = 0; i < Plus->uplist.n_uplines; i++) {	if (Plus->uplist.uplines[i] == line) {            G_debug(3, "/tskipped");	    return;        }    }#endif        /* Alloc space if needed */    if (Plus->uplist.n_uplines == Plus->uplist.alloc_uplines) {	Plus->uplist.alloc_uplines += 1000;	Plus->uplist.uplines =	    (int *)G_realloc(Plus->uplist.uplines,			     Plus->uplist.alloc_uplines * sizeof(int));	Plus->uplist.uplines_offset =	    (off_t *)G_realloc(Plus->uplist.uplines_offset,			     Plus->uplist.alloc_uplines * sizeof(off_t));    }    Plus->uplist.uplines[Plus->uplist.n_uplines] = line;    Plus->uplist.uplines_offset[Plus->uplist.n_uplines] = offset;    Plus->uplist.n_uplines++;}
开发者ID:rashadkm,项目名称:grass_cmake,代码行数:40,


示例3: draw_cell

static int draw_cell(int A_row,		     const void *array,		     struct Colors *colors, RASTER_MAP_TYPE data_type){    static unsigned char *red, *grn, *blu, *set;    static int nalloc;    int ncols = src[0][1] - src[0][0];    int i;    if (nalloc < ncols) {	nalloc = ncols;	red = G_realloc(red, nalloc);	grn = G_realloc(grn, nalloc);	blu = G_realloc(blu, nalloc);	set = G_realloc(set, nalloc);    }    Rast_lookup_colors(array, red, grn, blu, set, ncols, colors,			   data_type);    if (D__overlay_mode)	for (i = 0; i < ncols; i++) {	    set[i] = Rast_is_null_value(array, data_type);	    array = G_incr_void_ptr(array, Rast_cell_size(data_type));	}    A_row =	COM_raster(ncols, A_row, red, grn, blu, D__overlay_mode ? set : NULL);    return (A_row < src[1][1])	? A_row : -1;}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:33,


示例4: Vect_array_to_cat_list

/*!   /brief Convert ordered array of integers to cat_list structure.   /param vals array of integers   /param nvals number of values   /param[in,out] list pointer to cat_list structure   /return number of ranges */int Vect_array_to_cat_list(const int *vals, int nvals, struct cat_list *list){    int i, range;    G_debug(1, "Vect_array_to_cat_list()");    range = -1;    for (i = 0; i < nvals; i++) {	if (i == 0 || (vals[i] - list->max[range]) > 1) {	    range++;	    if (range == list->alloc_ranges) {		list->alloc_ranges += 1000;		list->min = (int *)G_realloc((void *)list->min,					     list->alloc_ranges *					     sizeof(int));		list->max =		    (int *)G_realloc((void *)list->max,				     list->alloc_ranges * sizeof(int));	    }	    list->min[range] = vals[i];	    list->max[range] = vals[i];	}	else {	    list->max[range] = vals[i];	}    }    list->n_ranges = range + 1;    return (list->n_ranges);}
开发者ID:rashadkm,项目名称:grass_cmake,代码行数:39,


示例5: I_new_control_point

int I_new_control_point(struct Control_Points *cp,			double e1, double n1, double e2, double n2,			int status){    int i;    unsigned int size;    if (status < 0)	return 1;    i = (cp->count)++;    size = cp->count * sizeof(double);    cp->e1 = (double *)G_realloc(cp->e1, size);    cp->e2 = (double *)G_realloc(cp->e2, size);    cp->n1 = (double *)G_realloc(cp->n1, size);    cp->n2 = (double *)G_realloc(cp->n2, size);    size = cp->count * sizeof(int);    cp->status = (int *)G_realloc(cp->status, size);    cp->e1[i] = e1;    cp->e2[i] = e2;    cp->n1[i] = n1;    cp->n2[i] = n2;    cp->status[i] = status;    return 0;}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:26,


示例6: G_rasprintf

int G_rasprintf(char **out, size_t *size, const char *fmt, ...){    va_list ap;    int count;    char *buf = *out;    size_t osize = *size;    if (osize < strlen(fmt) + 50) {	osize = strlen(fmt) + 50;	buf = G_realloc(buf, osize);    }    for (;;) {	va_start(ap, fmt);	count = vsnprintf(buf, osize, fmt, ap);	va_end(ap);	if (count >= 0 && count < osize)	    break;	if (count > -1)	    osize = count + 1;	else	    osize *= 2;		buf = G_realloc(buf, osize);    }    *out = buf;    *size = osize;    return count;}
开发者ID:rashadkm,项目名称:grass_cmake,代码行数:31,


示例7: G_vasprintf

int G_vasprintf(char **out, const char *fmt, va_list ap){#ifdef HAVE_ASPRINTF    return vasprintf(out, fmt, ap);#else    size_t size = strlen(fmt) + 50;    char *buf = G_malloc(size);    int count;    for (;;) {	/* BUG: according to man vsnprintf,	 * va_start() should be called immediately before vsnprintf(),	 * and va_end() immediately after vsnprintf()	 * otherwise there will be memory corruption */	count = vsnprintf(buf, size, fmt, ap);	if (count >= 0 && count < size)	    break;	size *= 2;	buf = G_realloc(buf, size);    }    buf = G_realloc(buf, count + 1);    *out = buf;    return count;#endif /* HAVE_ASPRINTF */}
开发者ID:rashadkm,项目名称:grass_cmake,代码行数:27,


示例8: I_new_ref_point

intI_new_ref_point(struct Ortho_Photo_Points *cp, double e1, double n1,		double e2, double n2, int status){    int i;    size_t size;    /*fprintf (stderr, "Try to new_ref_point /n"); */    if (status < 0)	return 0;    i = (cp->count)++;    size = cp->count * sizeof(double);    cp->e1 = (double *)G_realloc(cp->e1, size);    cp->e2 = (double *)G_realloc(cp->e2, size);    cp->n1 = (double *)G_realloc(cp->n1, size);    cp->n2 = (double *)G_realloc(cp->n2, size);    size = cp->count * sizeof(int);    cp->status = (int *)G_realloc(cp->status, size);    cp->e1[i] = e1;    cp->e2[i] = e2;    cp->n1[i] = n1;    cp->n2[i] = n2;    cp->status[i] = status;    return 0;}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:27,


示例9: newpoint

void newpoint(double z, double east, double north, int noindex){    int row, column;    row = (int)((window.north - north) / window.ns_res);    column = (int)((east - window.west) / window.ew_res);    if (!noindex) {        if (row < 0 || row >= window.rows || column < 0 ||                column >= window.cols) ;        else {			/* Ignore sites outside current region as can't be indexed */            points[row][column] =                (struct Point *)G_realloc(points[row][column],                                          (1 +                                           npoints_currcell[row][column]) *                                          sizeof(struct Point));            points[row][column][npoints_currcell[row][column]].north = north;            points[row][column][npoints_currcell[row][column]].east = east;            points[row][column][npoints_currcell[row][column]].z = z;            npoints_currcell[row][column]++;            npoints++;        }    }    else {        noidxpoints = (struct Point *)G_realloc(noidxpoints,                                                (1 +                                                        npoints) *                                                sizeof(struct Point));        noidxpoints[npoints].north = north;        noidxpoints[npoints].east = east;        noidxpoints[npoints].z = z;        npoints++;    }}
开发者ID:rkrug,项目名称:grass-ci,代码行数:35,


示例10: dig_boxlist_add

/* Add item to box list, does not check for duplicates */int dig_boxlist_add(struct boxlist *list, int id, struct bound_box box){    if (list->n_values == list->alloc_values) {	size_t size = (list->n_values + 1000) * sizeof(int);	void *p = G_realloc((void *)list->id, size);	if (p == NULL)	    return 0;	list->id = (int *)p;	if (list->have_boxes) {	    size = (list->n_values + 1000) * sizeof(struct bound_box);	    p = G_realloc((void *)list->box, size);	    if (p == NULL)		return 0;	    list->box = (struct bound_box *)p;	}	list->alloc_values = list->n_values + 1000;    }    list->id[list->n_values] = id;    if (list->have_boxes)	list->box[list->n_values] = box;    list->n_values++;    return 1;}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:30,


示例11: add_coor

void add_coor(SYMBCHAIN *chain, double x, double y){    G_debug(5, "    add_coor %f, %f", x, y);    if (chain->scount == chain->salloc) {	chain->salloc += 10;	chain->sx = (double *)G_realloc(chain->sx, chain->salloc * sizeof(double));	chain->sy = (double *)G_realloc(chain->sy, chain->salloc * sizeof(double));    }    chain->sx[chain->scount] = x;    chain->sy[chain->scount] = y;    chain->scount++;}
开发者ID:rashadkm,项目名称:grass_cmake,代码行数:12,


示例12: loadSiteCoordinates

int loadSiteCoordinates(struct Map_info *Map, struct Point **points, int region,			struct Cell_head *window, int field, struct cat_list *cat_list){    int i, pointIdx;    struct line_pnts *sites;    struct line_cats *cats;    struct bound_box box;    int type;    sites = Vect_new_line_struct();    cats = Vect_new_cats_struct();    *points = NULL;    pointIdx = 0;        /* copy window to box */    Vect_region_box(window, &box);    while ((type = Vect_read_next_line(Map, sites, cats)) > -1) {	if (type != GV_POINT && !(type & GV_LINES))	    continue;	if (field > 0 && !Vect_cats_in_constraint(cats, field, cat_list))	    continue;		for (i = 0; i < sites->n_points; i++) {	    G_debug(4, "Point: %f|%f|%f", sites->x[i], sites->y[i],		    sites->z[i]);	    	    if (region && !Vect_point_in_box(sites->x[i], sites->y[i], sites->z[i], &box))		continue;	    	    G_debug(4, "Point in the box");	    if ((pointIdx % ALLOC_CHUNK) == 0)		*points = (struct Point *) G_realloc(*points,						     (pointIdx + ALLOC_CHUNK) * sizeof(struct Point));	    	    (*points)[pointIdx].x = sites->x[i];	    (*points)[pointIdx].y = sites->y[i];	    (*points)[pointIdx].z = sites->z[i];	    pointIdx++;	}    }    if (pointIdx > 0)	*points = (struct Point *)G_realloc(*points,					    (pointIdx + 1) * sizeof(struct Point));        return pointIdx;}
开发者ID:rashadkm,项目名称:grass_cmake,代码行数:52,


示例13: D_draw_raster_RGB

/*!  /brief Draw raster row in RGB mode  /param A_row row number  /param r_raster red data buffer  /param g_raster green data buffer  /param b_raster blue data buffer  /param r_colors colors used for red channel  /param g_colors colors used for green channel  /param b_colors colors used for blue channel  /param r_type raster type used for red channel  /param g_type raster type used for red channel  /param b_type raster type used for red channel  /return*/int D_draw_raster_RGB(int A_row,		      const void *r_raster, const void *g_raster,		      const void *b_raster, struct Colors *r_colors,		      struct Colors *g_colors, struct Colors *b_colors,		      RASTER_MAP_TYPE r_type, RASTER_MAP_TYPE g_type,		      RASTER_MAP_TYPE b_type){    static unsigned char *r_buf, *g_buf, *b_buf, *n_buf;    static int nalloc;    int r_size = Rast_cell_size(r_type);    int g_size = Rast_cell_size(g_type);    int b_size = Rast_cell_size(b_type);    int ncols = src[0][1] - src[0][0];    int i;    /* reallocate color_buf if necessary */    if (nalloc < ncols) {	nalloc = ncols;	r_buf = G_realloc(r_buf, nalloc);	g_buf = G_realloc(g_buf, nalloc);	b_buf = G_realloc(b_buf, nalloc);	n_buf = G_realloc(n_buf, nalloc);    }    /* convert cell values to bytes */    Rast_lookup_colors(r_raster, r_buf, n_buf, n_buf, n_buf, ncols,			   r_colors, r_type);    Rast_lookup_colors(g_raster, n_buf, g_buf, n_buf, n_buf, ncols,			   g_colors, g_type);    Rast_lookup_colors(b_raster, n_buf, n_buf, b_buf, n_buf, ncols,			   b_colors, b_type);    if (D__overlay_mode)	for (i = 0; i < ncols; i++) {	    n_buf[i] = (Rast_is_null_value(r_raster, r_type) ||			Rast_is_null_value(g_raster, g_type) ||			Rast_is_null_value(b_raster, b_type));	    r_raster = G_incr_void_ptr(r_raster, r_size);	    g_raster = G_incr_void_ptr(g_raster, g_size);	    b_raster = G_incr_void_ptr(b_raster, b_size);	}    A_row = COM_raster(ncols, A_row, r_buf, g_buf, b_buf,		       D__overlay_mode ? n_buf : NULL);    return (A_row < src[1][1])	? A_row : -1;}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:66,


示例14: add_point

/* add point to line */void add_point(SYMBEL * el, double x, double y){    if (el->coor.line.count == el->coor.line.alloc) {	el->coor.line.alloc += 10;	el->coor.line.x =	    (double *)G_realloc(el->coor.line.x,				el->coor.line.alloc * sizeof(double));	el->coor.line.y =	    (double *)G_realloc(el->coor.line.y,				el->coor.line.alloc * sizeof(double));    }    el->coor.line.x[el->coor.line.count] = x;    el->coor.line.y[el->coor.line.count] = y;    el->coor.line.count++;}
开发者ID:GRASS-GIS,项目名称:grass-ci,代码行数:16,


示例15: scan_rules

/*!  /brief Get list of color rules for Option->options    /return allocated string buffer with options*/char *G_color_rules_options(void){    char *list, **rules;    const char *name;    int size, len, nrules;    int i, n;    list = NULL;    size = len = 0;    rules = scan_rules(&nrules);        for (i = 0; i < nrules; i++) {        name = rules[i];        n = strlen(name);        if (size < len + n + 2) {            size = len + n + 200;            list = G_realloc(list, size);        }        if (len > 0)            list[len++] = ',';        memcpy(&list[len], name, n + 1);        len += n;    }    G_free(rules);        return list;}
开发者ID:rashadkm,项目名称:grass_cmake,代码行数:37,


示例16: list_mon

/* get list of running monitors */void list_mon(char ***list, int *n){    int i;    const char *name;    const char *env_prefix = "MONITOR_";    int env_prefix_len;    char **tokens;        env_prefix_len = strlen(env_prefix);        *list = NULL;    *n    = 0;    tokens = NULL;    for (i = 0; (name = G_get_env_name(i)); i++) {	if (strncmp(env_prefix, name, env_prefix_len) == 0) {	    tokens = G_tokenize(name, "_");	    if (G_number_of_tokens(tokens) != 3 ||		strcmp(tokens[2], "ENVFILE") != 0)		continue;	    *list = G_realloc(*list, (*n + 1) * sizeof(char *));	    /* GRASS variable names are upper case, but monitor names are lower	     * case. */	    (*list)[*n] = G_store_lower(tokens[1]);	    (*n)++;	    G_free_tokens(tokens);	    tokens = NULL;	}    }    }
开发者ID:caomw,项目名称:grass,代码行数:31,


示例17: assert

char *G_rc_path(const char *element, const char *item){    size_t len;    char *path, *ptr;    assert(!(element == NULL && item == NULL));    /* Simple item in top-level */    if (element == NULL) {	path = _make_toplevel();    }    else if (item == NULL) {	return _make_sublevels(element);    }    else {	path = _make_sublevels(element);    }    assert(*item != '.');    assert(path != NULL);    ptr = strchr(item, '/');	/* should not have slashes */    assert(ptr == NULL);    len = strlen(path) + strlen(item) + 2;    if ((ptr = G_realloc(path, len)) == NULL) {	G_free(path);	return NULL;    }    path = ptr;    ptr = strchr(path, '/0');    sprintf(ptr, "/%s", item);    return path;}				/* G_rc_path */
开发者ID:rashadkm,项目名称:grass_cmake,代码行数:34,


示例18: _get_list

static void _get_list(char ***list, int *count){    char **a;    int n;    char *buf;    *list = NULL;    *count = 0;    buf = _get_text_2();    for (n = 0; *buf; n++) {	if (n == 0)	    a = G_malloc(sizeof(char *));	else	    a = G_realloc(a, (n + 1) * sizeof(char *));	a[n] = G_strdup(buf);	buf = _get_text_2();    }    *list = a;    *count = n;}
开发者ID:imincik,项目名称:pkg-grass,代码行数:25,


示例19: set_cat

int set_cat(CELL result, CELL * cat, struct Categories *pcats){    int i, n;    static char *buf = NULL;    static int len = 0;    char *lbl;    if (result == 0)	return 1;    n = 0;    for (i = 0; i < nfiles; i++) {	lbl = get_label(cat[i], &labels[i]);	n += strlen(lbl) + 2;    }    if (len < n)	buf = G_realloc(buf, len = n);    *buf = 0;    for (i = 0; i < nfiles; i++) {	if (i)	    strcat(buf, "; ");	lbl = get_label(cat[i], &labels[i]);	strcat(buf, lbl);    }    G_set_cat(result, buf, pcats);    return 0;}
开发者ID:imincik,项目名称:pkg-grass,代码行数:29,


示例20: add_to_list

static int add_to_list(int x, int y){    int n, i;    struct equiv_table *e_list_y;    e_list_y = e_list + y;    n = e_list_y->count;    if (n == 0) {		/* first time through--start list */	e_list_y->length = 20;	/* initial guess at storage needed */	e_list_y->ptr = (int *)G_malloc(e_list_y->length * sizeof(int));	*(e_list_y->ptr) = x;	(e_list_y->count)++;    }    else {			/* list already started */	for (i = 0; i < n; i++) {	/* check whether x is already *//*   in list */	    if (*(e_list_y->ptr + i) == x)		return (0);	/* if so, we don't need to add it */	}	if (n + 1 >= e_list_y->length) {	/* add more space for storage *//*   if necessary */	    e_list_y->length += 10;	    e_list_y->ptr =		(int *)G_realloc(e_list_y->ptr,				 e_list_y->length * sizeof(int));	}	*(e_list_y->ptr + n) = x;	/* add x to list */	(e_list_y->count)++;    }    return (1);			/* indicate addition made */}
开发者ID:imincik,项目名称:pkg-grass,代码行数:33,


示例21: strlen

static char *rules_list(void){    char *list = NULL;    int size = 0;    int len = 0;    int i;    for (i = 0; i < nrules; i++) {	const char *name = rules[i];	int n = strlen(name);	if (size < len + n + 2) {	    size = len + n + 200;	    list = G_realloc(list, size);	}	if (len > 0)	    list[len++] = ',';	memcpy(&list[len], name, n + 1);	len += n;    }    return list;}
开发者ID:imincik,项目名称:pkg-grass,代码行数:25,


示例22: sizeof

struct SubSig *I_NewSubSig(struct SigSet *S, struct ClassSig *C){    struct SubSig *Sp;    int i;    if (C->nsubclasses == 0)	C->SubSig = (struct SubSig *)G_malloc(sizeof(struct SubSig));    else	C->SubSig = (struct SubSig *)G_realloc((char *)C->SubSig,					       sizeof(struct SubSig) *					       (C->nsubclasses + 1));    Sp = &C->SubSig[C->nsubclasses++];    Sp->used = 1;    Sp->R = (double **)G_calloc(S->nbands, sizeof(double *));    Sp->R[0] = (double *)G_calloc(S->nbands * S->nbands, sizeof(double));    for (i = 1; i < S->nbands; i++)	Sp->R[i] = Sp->R[i - 1] + S->nbands;    Sp->Rinv = (double **)G_calloc(S->nbands, sizeof(double *));    Sp->Rinv[0] = (double *)G_calloc(S->nbands * S->nbands, sizeof(double));    for (i = 1; i < S->nbands; i++)	Sp->Rinv[i] = Sp->Rinv[i - 1] + S->nbands;    Sp->means = (double *)G_calloc(S->nbands, sizeof(double));    Sp->N = 0;    Sp->pi = 0;    Sp->cnst = 0;    return Sp;}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:28,


示例23: try_get_colors

static int try_get_colors(Colormap cmap, int nr, int ng, int nb){    XColor xcolor;    int n_pixels;    int r, g, b;    xpixels = (unsigned long *)G_realloc(xpixels,					 nr * ng * nb *					 sizeof(unsigned long));    n_pixels = 0;    xcolor.flags = DoRed | DoGreen | DoBlue;    for (r = 0; r < nr; r++) {	for (g = 0; g < ng; g++) {	    for (b = 0; b < nb; b++) {		xcolor.red = (unsigned short)(r * 0xFFFF / (nr - 1));		xcolor.green = (unsigned short)(g * 0xFFFF / (ng - 1));		xcolor.blue = (unsigned short)(b * 0xFFFF / (nb - 1));		if (!XAllocColor(dpy, cmap, &xcolor)) {		    XFreeColors(dpy, cmap, xpixels, n_pixels,				(unsigned long)0);		    return 0;		}		xpixels[n_pixels++] = xcolor.pixel;	    }	}    }    return 1;}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:32,


示例24: add_table

/* add table to database */int add_table(char *table, char *name){    G_debug(2, "add_table(): table = %s name = %s", table, name);    if (db.atables == db.ntables) {        db.atables += 15;        db.tables =            (TABLE *) G_realloc(db.tables, db.atables * sizeof(TABLE));    }    strcpy(db.tables[db.ntables].name, table);#ifdef __MINGW32__    sprintf(db.tables[db.ntables].file, "%s//%s", db.name, name);#else    sprintf(db.tables[db.ntables].file, "%s/%s", db.name, name);#endif    db.tables[db.ntables].alive = TRUE;    db.tables[db.ntables].described = FALSE;    db.tables[db.ntables].loaded = FALSE;    db.tables[db.ntables].updated = FALSE;    db.tables[db.ntables].cols = NULL;    db.tables[db.ntables].rows = NULL;    db.tables[db.ntables].acols = 0;    db.tables[db.ntables].ncols = 0;    db.tables[db.ntables].arows = 0;    db.tables[db.ntables].nrows = 0;    db.ntables++;    return DB_OK;}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:34,


示例25: ensure

static void ensure(struct buffer *b, size_t n){    if (b->size <= b->len + n + 1) {	b->size = b->len + n + INCREMENT;	b->str = G_realloc(b->str, b->size);    }}
开发者ID:rashadkm,项目名称:grass_cmake,代码行数:7,


示例26: try_get_grays

static int try_get_grays(Colormap cmap, int ny){    XColor xcolor;    int n_pixels;    int y;    xpixels = (unsigned long *)G_realloc(xpixels, ny * sizeof(unsigned long));    n_pixels = 0;    xcolor.flags = DoRed | DoGreen | DoBlue;    for (y = 0; y < ny; y++) {	unsigned short v = (unsigned short)(y * 0xFFFF / (ny - 1));	xcolor.red = v;	xcolor.green = v;	xcolor.blue = v;	if (!XAllocColor(dpy, cmap, &xcolor)) {	    XFreeColors(dpy, cmap, xpixels, n_pixels, (unsigned long)0);	    return y;	}	xpixels[n_pixels++] = xcolor.pixel;    }    return ny;}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:28,


示例27: add_search_dir

static void add_search_dir(const char *name){    char envvar_name[256];    char *fullname = NULL;    if (sscanf(name, "${%255[^}]}", envvar_name) == 1) {	char *envvar_value = getenv(envvar_name);	/* N.B. If the envvar isn't set, directory is skipped completely */	if (envvar_value)	    G_asprintf(&fullname, "%s%s", envvar_value,		       (name + strlen(envvar_name) + 3));    }    else	fullname = G_store(name);    if (fullname) {	searchdirs = (char **)G_realloc(searchdirs,					(numsearchdirs + 1) * sizeof(char *));	searchdirs[numsearchdirs] = fullname;	G_convert_dirseps_to_host(searchdirs[numsearchdirs]);	numsearchdirs++;    }    return;}
开发者ID:imincik,项目名称:pkg-grass,代码行数:26,


示例28: draw_bitmap

static void draw_bitmap(FT_Bitmap * bitmap, FT_Int x, FT_Int y){    static unsigned char *buf;    static int nalloc;    int w, h;    int bw = bitmap->width;    int bh = bitmap->rows;    const unsigned char *sbuf = bitmap->buffer;    int offset, i, j;    double x1, y1, x2, y2;    x1 = x;    y1 = y;    x2 = x1 + bw;    y2 = y1 + bh;    w = x2 - x1;    h = y2 - y1;    if (w <= 0 || h <= 0)	return;    offset = ((int)y1 - y) * bw + (int)x1 - x;    if (nalloc < w * h) {	nalloc = w * h;	buf = G_realloc(buf, nalloc);    }    for (j = 0; j < h; j++)	for (i = 0; i < w; i++)	    buf[j * w + i] = sbuf[offset + j * bw + i];    COM_Pos_abs(x1, y1);    COM_Bitmap(w, h, 128, buf);}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:35,


示例29: dig_node_add_updated

/*!   /brief Add node to updated   /param Plus pointer to Plus_head structure   /param node node id */void dig_node_add_updated(struct Plus_head *Plus, int node){    int i;    G_debug(3, "dig_node_add_updated(): node = %d", node);    /* Check if already in list */    for (i = 0; i < Plus->uplist.n_upnodes; i++) {	if (abs(Plus->uplist.upnodes[i]) == abs(node)) {            G_debug(3, "/tskipped");	    return;        }    }    /* Alloc space if needed */    if (Plus->uplist.n_upnodes == Plus->uplist.alloc_upnodes) {	Plus->uplist.alloc_upnodes += 1000;	Plus->uplist.upnodes =	    (int *)G_realloc(Plus->uplist.upnodes,			     Plus->uplist.alloc_upnodes * sizeof(int));    }    Plus->uplist.upnodes[Plus->uplist.n_upnodes] = node;    Plus->uplist.n_upnodes++;}
开发者ID:caomw,项目名称:grass,代码行数:31,


示例30: GS_get_surf_list

/*! Add new fringe  /param data nviz data  /param id surface id  /param color color  /param elev fringe elevation  /param nw,ne,sw,se 1 (turn on) 0 (turn off)  /return pointer to allocated fringe_data structure  /return NULL on error*/struct fringe_data *Nviz_new_fringe(nv_data *data,				    int id, unsigned long color,				    double elev, int nw, int ne, int sw, int se){    int num;    int *surf;    struct fringe_data *f;    if (!GS_surf_exists(id)) {	/* select first surface from the list */	surf = GS_get_surf_list(&num);	if (num < 1)	    return NULL;	id = surf[0];	G_free(surf);    }         f = (struct fringe_data *) G_malloc(sizeof(struct fringe_data));    f->id = id;    f->color = color;    f->elev = elev;    f->where[0] = nw;    f->where[1] = ne;    f->where[2] = sw;    f->where[3] = se;    data->fringe = (struct fringe_data **) G_realloc(data->fringe, data->num_fringes + 1 * sizeof(struct fringe_data *));    data->fringe[data->num_fringes++] = f;        return f;}
开发者ID:rashadkm,项目名称:grass_cmake,代码行数:43,



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


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