1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-12-23 12:32:24 +02:00

eeshow/cro.c (new_cc): separate context creation from option parsing

This commit is contained in:
Werner Almesberger 2016-08-08 16:52:10 -03:00
parent 52ab16d62a
commit a564b5d03e

View File

@ -255,10 +255,9 @@ static const struct gfx_ops real_cro_ops = {
};
static struct cro_ctx *init_common(int argc, char *const *argv)
static struct cro_ctx *new_cc(void)
{
struct cro_ctx *cc;
char c;
cc = alloc_type(struct cro_ctx);
cc->xo = cc->yo = 0;
@ -270,6 +269,22 @@ static struct cro_ctx *init_common(int argc, char *const *argv)
cc->color_override = COLOR_NONE;
cc->output_name = NULL;
/*
* record_init does not perform allocations or such, so it's safe to
* call it here even if we don't use this facility.
*/
record_init(&cc->record, &real_cro_ops, cc);
return cc;
}
static struct cro_ctx *init_common(int argc, char *const *argv)
{
struct cro_ctx *cc = new_cc();
char c;
while ((c = getopt(argc, argv, "o:s:")) != EOF)
switch (c) {
case 'o':
@ -282,8 +297,6 @@ static struct cro_ctx *init_common(int argc, char *const *argv)
usage(*argv);
}
record_init(&cc->record, &real_cro_ops, cc);
return cc;
}