1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2025-04-21 12:27:27 +03:00

eeshow/misc/util.h (realloc_size, realloc_type_n): get rid of bare "realloc"

Finally ! Shoulds have done this a long time ago.
This commit is contained in:
Werner Almesberger
2016-08-22 21:00:10 -03:00
parent 1b250bd467
commit 465a36fde5
9 changed files with 25 additions and 29 deletions

View File

@@ -404,9 +404,7 @@ static void cr_pdf_new_sheet(void *ctx)
struct cro_ctx *cc = ctx;
cc->n_sheets++;
cc->sheets = realloc(cc->sheets, sizeof(struct record) * cc->n_sheets);
if (!cc->sheets)
diag_pfatal("realloc");
cc->sheets = realloc_type_n(cc->sheets, struct record, cc->n_sheets);
cc->sheets[cc->n_sheets - 1] = cc->record;
record_wipe(&cc->record);
}

View File

@@ -262,7 +262,7 @@ static void *fig_init(int argc, char *const *argv)
if (!strchr(argv[arg], '='))
usage(*argv);
n_vars++;
vars = realloc(vars, sizeof(const char *) * n_vars);
vars = realloc_type_n(vars, const char *, n_vars);
vars[n_vars - 1] = argv[arg];
}

View File

@@ -114,8 +114,7 @@ static void add_object(struct pdftoc *ctx, int id, int gen, unsigned pos)
struct object *obj;
if (id > ctx->top) {
ctx->objs = realloc(ctx->objs,
(id + 1) * sizeof(struct object));
ctx->objs = realloc_type_n(ctx->objs, struct object, id + 1);
memset(ctx->objs + ctx->top + 1 , 0,
(id - ctx->top) * sizeof(struct object));
ctx->top = id;