From 8f7af0acaf8a9253242d89fcdb26e285841f7833 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Sat, 2 Oct 2021 06:47:31 +0200 Subject: [PATCH] Replace numerous instances of xzalloc with XZALLOC --- src/data/casereader-translator.c | 2 +- src/data/dataset.c | 4 +--- src/data/dictionary.c | 2 +- src/data/file-handle-def.c | 2 +- src/data/mdd-writer.c | 2 +- src/data/ods-reader.c | 4 ++-- src/data/pc+-file-reader.c | 3 +-- src/data/psql-reader.c | 2 +- src/data/sys-file-reader.c | 3 +-- src/data/sys-file-writer.c | 3 +-- src/data/variable.c | 3 +-- src/language/dictionary/mrsets.c | 3 +-- src/language/stats/aggregate.c | 2 +- src/language/stats/autorecode.c | 2 +- src/language/stats/factor.c | 2 +- src/language/stats/means.c | 2 +- src/language/stats/median.c | 2 +- src/language/stats/oneway.c | 2 +- src/libpspp/argv-parser.c | 2 +- src/libpspp/zip-reader.c | 4 ++-- src/math/box-whisker.c | 5 ++--- src/math/categoricals.c | 2 +- src/math/covariance.c | 2 +- src/math/levene.c | 4 ++-- src/math/np.c | 2 +- src/math/percentiles.c | 2 +- src/math/shapiro-wilk.c | 2 +- src/math/trimmed-mean.c | 2 +- src/math/tukey-hinges.c | 2 +- src/output/ascii.c | 4 +--- src/output/cairo.c | 2 +- src/output/charts/barchart.c | 7 +++---- src/output/charts/np-plot.c | 4 +--- src/output/charts/scatterplot.c | 4 +--- src/output/charts/spreadlevel-plot.c | 2 +- src/output/csv.c | 3 +-- src/output/driver.c | 2 +- src/output/html.c | 4 +--- src/output/msglog.c | 3 +-- src/output/odt.c | 3 +-- src/output/output-item.c | 2 +- src/output/pivot-table.c | 4 ++-- src/output/render.c | 2 +- src/output/spv-driver.c | 4 +--- src/output/spv/spv-legacy-decoder.c | 12 ++++++------ src/output/spv/spv-light-decoder.c | 8 ++++---- src/ui/gui/find-dialog.c | 6 +++--- src/ui/gui/psppire-import-textfile.c | 2 +- src/ui/gui/psppire-output-window.c | 3 +-- src/ui/terminal/terminal-opts.c | 4 +--- src/ui/terminal/terminal-reader.c | 4 +--- 51 files changed, 68 insertions(+), 95 deletions(-) diff --git a/src/data/casereader-translator.c b/src/data/casereader-translator.c index 3567f5c3a5..831077466b 100644 --- a/src/data/casereader-translator.c +++ b/src/data/casereader-translator.c @@ -309,7 +309,7 @@ struct casereader * casereader_create_arithmetic_sequence (struct casereader *subreader, double first, double increment) { - struct arithmetic_sequence *as = xzalloc (sizeof *as); + struct arithmetic_sequence *as = XZALLOC (struct arithmetic_sequence); as->first = first; as->increment = increment; return casereader_create_append_numeric (subreader, next_arithmetic, diff --git a/src/data/dataset.c b/src/data/dataset.c index f966b63af9..10005e0aca 100644 --- a/src/data/dataset.c +++ b/src/data/dataset.c @@ -143,9 +143,7 @@ dataset_create_finish__ (struct dataset *ds, struct session *session) struct dataset * dataset_create (struct session *session, const char *name) { - struct dataset *ds; - - ds = xzalloc (sizeof *ds); + struct dataset *ds = XZALLOC (struct dataset); ds->name = xstrdup (name); ds->display = DATASET_FRONT; ds->dict = dict_create (get_default_encoding ()); diff --git a/src/data/dictionary.c b/src/data/dictionary.c index 9c73e0ea44..ab4642a4da 100644 --- a/src/data/dictionary.c +++ b/src/data/dictionary.c @@ -250,7 +250,7 @@ dict_copy_callbacks (struct dictionary *dest, struct dictionary * dict_create (const char *encoding) { - struct dictionary *d = xzalloc (sizeof *d); + struct dictionary *d = XZALLOC (struct dictionary); d->encoding = xstrdup (encoding); d->names_must_be_ids = true; diff --git a/src/data/file-handle-def.c b/src/data/file-handle-def.c index 075f7b0790..de09ae39a7 100644 --- a/src/data/file-handle-def.c +++ b/src/data/file-handle-def.c @@ -221,7 +221,7 @@ static struct file_handle * create_handle (const char *id, char *handle_name, enum fh_referent referent, const char *encoding) { - struct file_handle *handle = xzalloc (sizeof *handle); + struct file_handle *handle = XZALLOC (struct file_handle); handle->ref_cnt = 1; handle->id = xstrdup_if_nonnull (id); diff --git a/src/data/mdd-writer.c b/src/data/mdd-writer.c index 5e5eaa743d..10728e8cbd 100644 --- a/src/data/mdd-writer.c +++ b/src/data/mdd-writer.c @@ -448,7 +448,7 @@ bool mdd_write (struct file_handle *fh, struct dictionary *dict, const char *sav_name) { - struct mdd_writer *w = xzalloc (sizeof *w); + struct mdd_writer *w = XZALLOC (struct mdd_writer); size_t n_vars = dict_get_var_cnt (dict); /* Open file handle as an exclusive writer. */ diff --git a/src/data/ods-reader.c b/src/data/ods-reader.c index b014a748d7..2ff12fe109 100644 --- a/src/data/ods-reader.c +++ b/src/data/ods-reader.c @@ -1079,7 +1079,7 @@ ods_file_casereader_read (struct casereader *reader UNUSED, void *r_) r->rsd.node_type == XML_READER_TYPE_TEXT) { int col; - struct xml_value *xmv = xzalloc (sizeof *xmv); + struct xml_value *xmv = XZALLOC (struct xml_value); xmv->text = xmlTextReaderValue (r->rsd.xtr); xmv->value = val_string; val_string = NULL; @@ -1163,7 +1163,7 @@ init_reader (struct ods_reader *r, bool report_errors, struct spreadsheet * ods_probe (const char *filename, bool report_errors) { - struct ods_reader *r = xzalloc (sizeof *r); + struct ods_reader *r = XZALLOC (struct ods_reader); struct zip_reader *zr; char *error = zip_reader_create (filename, &zr); diff --git a/src/data/pc+-file-reader.c b/src/data/pc+-file-reader.c index 8b945788a5..4753881a67 100644 --- a/src/data/pc+-file-reader.c +++ b/src/data/pc+-file-reader.c @@ -190,11 +190,10 @@ static bool parse_variable_records (struct pcp_reader *, struct dictionary *, static struct any_reader * pcp_open (struct file_handle *fh) { - struct pcp_reader *r; struct stat s; /* Create and initialize reader. */ - r = xzalloc (sizeof *r); + struct pcp_reader *r = XZALLOC (struct pcp_reader); r->any_reader.klass = &pcp_file_reader_class; r->pool = pool_create (); pool_register (r->pool, free, r); diff --git a/src/data/psql-reader.c b/src/data/psql-reader.c index 6780138b08..a38c9e9030 100644 --- a/src/data/psql-reader.c +++ b/src/data/psql-reader.c @@ -233,7 +233,7 @@ psql_open_reader (struct psql_read_info *info, struct dictionary **dict) casenumber n_cases = CASENUMBER_MAX; const char *encoding; - struct psql_reader *r = xzalloc (sizeof *r); + struct psql_reader *r = XZALLOC (struct psql_reader); struct string query ; r->conn = PQconnectdb (info->conninfo); diff --git a/src/data/sys-file-reader.c b/src/data/sys-file-reader.c index f11480ac8f..109b0dd16e 100644 --- a/src/data/sys-file-reader.c +++ b/src/data/sys-file-reader.c @@ -391,10 +391,9 @@ static struct any_reader * sfm_open (struct file_handle *fh) { size_t allocated_mrsets = 0; - struct sfm_reader *r; /* Create and initialize reader. */ - r = xzalloc (sizeof *r); + struct sfm_reader *r = XZALLOC (struct sfm_reader); r->any_reader.klass = &sys_file_reader_class; r->pool = pool_create (); pool_register (r->pool, free, r); diff --git a/src/data/sys-file-writer.c b/src/data/sys-file-writer.c index 7a0fb5a691..54282a95f3 100644 --- a/src/data/sys-file-writer.c +++ b/src/data/sys-file-writer.c @@ -200,7 +200,6 @@ sfm_open_writer (struct file_handle *fh, struct dictionary *d, struct sfm_write_options opts) { struct encoding_info encoding_info; - struct sfm_writer *w; mode_t mode; int i; @@ -213,7 +212,7 @@ sfm_open_writer (struct file_handle *fh, struct dictionary *d, } /* Create and initialize writer. */ - w = xzalloc (sizeof *w); + struct sfm_writer *w = XZALLOC (struct sfm_writer); w->fh = fh_ref (fh); w->lock = NULL; w->file = NULL; diff --git a/src/data/variable.c b/src/data/variable.c index 4859b1303f..3f32fa5d02 100644 --- a/src/data/variable.c +++ b/src/data/variable.c @@ -128,12 +128,11 @@ static void var_set_name_quiet (struct variable *v, const char *name); struct variable * var_create (const char *name, int width) { - struct variable *v; enum val_type type; assert (width >= 0 && width <= MAX_STRING); - v = xzalloc (sizeof *v); + struct variable *v = XZALLOC (struct variable); var_set_name_quiet (v, name); v->width = width; mv_init (&v->miss, width); diff --git a/src/language/dictionary/mrsets.c b/src/language/dictionary/mrsets.c index 5f544766e1..3b96da3a6c 100644 --- a/src/language/dictionary/mrsets.c +++ b/src/language/dictionary/mrsets.c @@ -79,11 +79,10 @@ parse_group (struct lexer *lexer, struct dictionary *dict, enum mrset_type type) { const char *subcommand_name = type == MRSET_MD ? "MDGROUP" : "MCGROUP"; - struct mrset *mrset; bool labelsource_varlabel; bool has_value; - mrset = xzalloc (sizeof *mrset); + struct mrset *mrset = XZALLOC (struct mrset); mrset->type = type; mrset->cat_source = MRSET_VARLABELS; diff --git a/src/language/stats/aggregate.c b/src/language/stats/aggregate.c index 565e26d938..86e11e07d7 100644 --- a/src/language/stats/aggregate.c +++ b/src/language/stats/aggregate.c @@ -565,7 +565,7 @@ parse_aggregate_functions (struct lexer *lexer, const struct dictionary *dict, variables. */ for (i = 0; i < n_dest; i++) { - struct agr_var *v = xzalloc (sizeof *v); + struct agr_var *v = XZALLOC (struct agr_var); /* Add variable to chain. */ if (agr->agr_vars != NULL) diff --git a/src/language/stats/autorecode.c b/src/language/stats/autorecode.c index 6481a26326..1a74b1e4a9 100644 --- a/src/language/stats/autorecode.c +++ b/src/language/stats/autorecode.c @@ -132,7 +132,7 @@ cmd_autorecode (struct lexer *lexer, struct dataset *ds) bool print = false; /* Create procedure. */ - struct autorecode_pgm *arc = xzalloc (sizeof *arc); + struct autorecode_pgm *arc = XZALLOC (struct autorecode_pgm); arc->blank_valid = true; /* Parse variable lists. */ diff --git a/src/language/stats/factor.c b/src/language/stats/factor.c index 4feece0da0..8a5efac14b 100644 --- a/src/language/stats/factor.c +++ b/src/language/stats/factor.c @@ -250,7 +250,7 @@ struct idata static struct idata * idata_alloc (size_t n_vars) { - struct idata *id = xzalloc (sizeof (*id)); + struct idata *id = XZALLOC (struct idata); id->n_extractions = 0; id->msr = gsl_vector_alloc (n_vars); diff --git a/src/language/stats/means.c b/src/language/stats/means.c index 2235433fb9..0a3b413df7 100644 --- a/src/language/stats/means.c +++ b/src/language/stats/means.c @@ -300,7 +300,7 @@ generate_cell (const struct means *means, const struct workspace *ws) { int n_vars = count_one_bits (not_wild); - struct cell *cell = xzalloc ((sizeof *cell)); + struct cell *cell = XZALLOC (struct cell); cell->values = xcalloc (n_vars, sizeof *cell->values); cell->vars = xcalloc (n_vars, sizeof *cell->vars); cell->not_wild = not_wild; diff --git a/src/language/stats/median.c b/src/language/stats/median.c index 9c35c15a45..8fa38c5a69 100644 --- a/src/language/stats/median.c +++ b/src/language/stats/median.c @@ -134,7 +134,7 @@ median_execute (const struct dataset *ds, if (n_sample_test == false) { - struct val_node *vn = xzalloc (sizeof *vn); + struct val_node *vn = XZALLOC (struct val_node); value_clone (&vn->val, &nst->val1, var_get_width (nst->indep_var)); hmap_insert (&map, &vn->node, value_hash (&nst->val1, var_get_width (nst->indep_var), 0)); diff --git a/src/language/stats/oneway.c b/src/language/stats/oneway.c index 2f1f299839..a612862556 100644 --- a/src/language/stats/oneway.c +++ b/src/language/stats/oneway.c @@ -526,7 +526,7 @@ cmd_oneway (struct lexer *lexer, struct dataset *ds) } else if (lex_match_id (lexer, "CONTRAST")) { - struct contrasts_node *cl = xzalloc (sizeof *cl); + struct contrasts_node *cl = XZALLOC (struct contrasts_node); struct ll_list *coefficient_list = &cl->coefficient_list; lex_match (lexer, T_EQUALS); diff --git a/src/libpspp/argv-parser.c b/src/libpspp/argv-parser.c index 97ec02834a..48c89cd6d4 100644 --- a/src/libpspp/argv-parser.c +++ b/src/libpspp/argv-parser.c @@ -43,7 +43,7 @@ struct argv_parser struct argv_parser * argv_parser_create (void) { - struct argv_parser *ap = xzalloc (sizeof *ap); + struct argv_parser *ap = XZALLOC (struct argv_parser); return ap; } diff --git a/src/libpspp/zip-reader.c b/src/libpspp/zip-reader.c index d33e5f930e..00249e0bae 100644 --- a/src/libpspp/zip-reader.c +++ b/src/libpspp/zip-reader.c @@ -378,7 +378,7 @@ zip_reader_create (const char *file_name, struct zip_reader **zrp) return NULL; } - struct zip_reader *zr = xzalloc (sizeof *zr); + struct zip_reader *zr = XZALLOC (struct zip_reader); zr->ref_cnt = 1; zr->file_name = xstrdup (file_name); zr->entries = xcalloc (n_members, sizeof *zr->entries); @@ -668,7 +668,7 @@ static char * inflate_init (struct zip_member *zm) { int r; - struct inflator *inf = xzalloc (sizeof *inf); + struct inflator *inf = XZALLOC (struct inflator); uint16_t flg = 0 ; uint16_t cmf = 0x8; /* Always 8 for inflate */ diff --git a/src/math/box-whisker.c b/src/math/box-whisker.c index 344561a6fd..4bbe0f5850 100644 --- a/src/math/box-whisker.c +++ b/src/math/box-whisker.c @@ -61,7 +61,6 @@ acc (struct statistic *s, const struct ccase *cx, { struct box_whisker *bw = UP_CAST (s, struct box_whisker, parent.parent); bool extreme; - struct outlier *o; if (y > bw->hinges[2] + bw->step) /* Upper outlier */ { @@ -86,7 +85,7 @@ acc (struct statistic *s, const struct ccase *cx, /* y is an outlier */ - o = xzalloc (sizeof *o) ; + struct outlier *o = xzalloc (sizeof *o) ; o->value = y; o->extreme = extreme; ds_init_empty (&o->label); @@ -145,7 +144,7 @@ struct box_whisker * box_whisker_create (const struct tukey_hinges *th, size_t id_idx, const struct variable *id_var) { - struct box_whisker *w = xzalloc (sizeof (*w)); + struct box_whisker *w = XZALLOC (struct box_whisker); struct order_stats *os = &w->parent; struct statistic *stat = &os->parent; diff --git a/src/math/categoricals.c b/src/math/categoricals.c index 28d51a9dd7..83326c3f00 100644 --- a/src/math/categoricals.c +++ b/src/math/categoricals.c @@ -323,7 +323,7 @@ struct categoricals * categoricals_create (struct interaction *const *inter, size_t n_inter, const struct variable *wv, enum mv_class fctr_excl) { - struct categoricals *cat = xzalloc (sizeof *cat); + struct categoricals *cat = XZALLOC (struct categoricals); cat->iap = pool_calloc (cat->pool, n_inter, sizeof *cat->iap); cat->n_iap = n_inter; cat->wv = wv; diff --git a/src/math/covariance.c b/src/math/covariance.c index dec5ee87cc..67a9fe9f21 100644 --- a/src/math/covariance.c +++ b/src/math/covariance.c @@ -145,7 +145,7 @@ covariance_1pass_create (size_t n_vars, const struct variable *const *vars, bool centered) { size_t i; - struct covariance *cov = xzalloc (sizeof *cov); + struct covariance *cov = XZALLOC (struct covariance); cov->centered = centered; cov->passes = 1; diff --git a/src/math/levene.c b/src/math/levene.c index 5785623a6a..a005c94360 100644 --- a/src/math/levene.c +++ b/src/math/levene.c @@ -118,7 +118,7 @@ find_group (const struct levene *nl, const union value *target) struct levene * levene_create (int indep_width, const union value *cutpoint) { - struct levene *nl = xzalloc (sizeof *nl); + struct levene *nl = XZALLOC (struct levene); hmap_init (&nl->hmap); @@ -146,7 +146,7 @@ levene_pass_one (struct levene *nl, double value, double weight, const union val if (NULL == lev) { - struct lev *l = xzalloc (sizeof *l); + struct lev *l = XZALLOC (struct lev); value_clone (&l->group, gv, nl->gvw); hmap_insert (&nl->hmap, &l->node, nl->hash (nl, &l->group)); lev = l; diff --git a/src/math/np.c b/src/math/np.c index 8b7d09e7d3..0d691c2aa7 100644 --- a/src/math/np.c +++ b/src/math/np.c @@ -74,7 +74,7 @@ acc (struct statistic *s, const struct ccase *cx UNUSED, struct np * np_create (double n, double mean, double var) { - struct np *np = xzalloc (sizeof (*np)); + struct np *np = XZALLOC (struct np); struct order_stats *os = &np->parent; struct statistic *stat = &os->parent; struct caseproto *proto; diff --git a/src/math/percentiles.c b/src/math/percentiles.c index a387d3d4c2..2d779e5bea 100644 --- a/src/math/percentiles.c +++ b/src/math/percentiles.c @@ -152,7 +152,7 @@ destroy (struct statistic *stat) struct percentile * percentile_create (double p, double W) { - struct percentile *ptl = xzalloc (sizeof (*ptl)); + struct percentile *ptl = XZALLOC (struct percentile); struct order_stats *os = &ptl->parent; struct statistic *stat = &os->parent; diff --git a/src/math/shapiro-wilk.c b/src/math/shapiro-wilk.c index 30feb39d9d..6d10722297 100644 --- a/src/math/shapiro-wilk.c +++ b/src/math/shapiro-wilk.c @@ -119,7 +119,7 @@ shapiro_wilk_create (int n, double mean) if (n < 3 || n > 5000) return NULL; - struct shapiro_wilk *sw = xzalloc (sizeof (*sw)); + struct shapiro_wilk *sw = XZALLOC (struct shapiro_wilk); struct order_stats *os = &sw->parent; struct statistic *stat = &os->parent; diff --git a/src/math/trimmed-mean.c b/src/math/trimmed-mean.c index d75b539a66..b643651a26 100644 --- a/src/math/trimmed-mean.c +++ b/src/math/trimmed-mean.c @@ -52,7 +52,7 @@ destroy (struct statistic *s) struct trimmed_mean * trimmed_mean_create (double W, double tail) { - struct trimmed_mean *tm = xzalloc (sizeof (*tm)); + struct trimmed_mean *tm = XZALLOC (struct trimmed_mean); struct order_stats *os = &tm->parent; struct statistic *stat = &os->parent; diff --git a/src/math/tukey-hinges.c b/src/math/tukey-hinges.c index c483a508c5..aaf4881afa 100644 --- a/src/math/tukey-hinges.c +++ b/src/math/tukey-hinges.c @@ -74,7 +74,7 @@ struct tukey_hinges * tukey_hinges_create (double W, double c_min) { double d; - struct tukey_hinges *th = xzalloc (sizeof (*th)); + struct tukey_hinges *th = XZALLOC (struct tukey_hinges); struct order_stats *os = &th->parent; struct statistic *stat = &os->parent; diff --git a/src/output/ascii.c b/src/output/ascii.c index f0be586dbd..a6bcb106d6 100644 --- a/src/output/ascii.c +++ b/src/output/ascii.c @@ -370,9 +370,7 @@ ascii_create (struct file_handle *fh, enum settings_output_devices device_type, { enum { BOX_ASCII, BOX_UNICODE } box; struct output_driver *d; - struct ascii_driver *a; - - a = xzalloc (sizeof *a); + struct ascii_driver *a = XZALLOC (struct ascii_driver); d = &a->driver; output_driver_init (&a->driver, &ascii_driver_class, fh_get_file_name (fh), device_type); a->append = parse_boolean (opt (d, o, "append", "false")); diff --git a/src/output/cairo.c b/src/output/cairo.c index dc5cf94ca3..a08771bb44 100644 --- a/src/output/cairo.c +++ b/src/output/cairo.c @@ -187,7 +187,7 @@ static struct xr_driver * xr_allocate (const char *name, int device_type, enum xr_output_type output_type, struct string_map *o) { - struct xr_driver *xr = xzalloc (sizeof *xr); + struct xr_driver *xr = XZALLOC (struct xr_driver); struct output_driver *d = &xr->driver; output_driver_init (d, &cairo_driver_class, name, device_type); diff --git a/src/output/charts/barchart.c b/src/output/charts/barchart.c index f987794004..1b946fddff 100644 --- a/src/output/charts/barchart.c +++ b/src/output/charts/barchart.c @@ -175,7 +175,6 @@ barchart_create (const struct variable **var, int n_vars, const char *ylabel, bool percent, struct freq *const *cats, int n_cats) { - struct barchart *bar; int i; const int pidx = 0; @@ -186,7 +185,7 @@ barchart_create (const struct variable **var, int n_vars, assert (n_vars >= 1 && n_vars <= 2); - bar = xzalloc (sizeof *bar); + struct barchart *bar = XZALLOC (struct barchart); bar->percent = percent; bar->var = var; bar->n_vars = n_vars; @@ -222,7 +221,7 @@ barchart_create (const struct variable **var, int n_vars, if (!flag) { - struct category *s = xzalloc (sizeof *s); + struct category *s = XZALLOC (struct category); s->idx = idx++; s->width = var_get_width (var[pidx]); value_init (&s->val, s->width); @@ -260,7 +259,7 @@ barchart_create (const struct variable **var, int n_vars, if (!flag) { - struct category *s = xzalloc (sizeof *s); + struct category *s = XZALLOC (struct category); s->idx = idx++; s->width = var_get_width (var[sidx]); value_init (&s->val, s->width); diff --git a/src/output/charts/np-plot.c b/src/output/charts/np-plot.c index b0235924f8..eeffbc1fa1 100644 --- a/src/output/charts/np-plot.c +++ b/src/output/charts/np-plot.c @@ -31,12 +31,10 @@ static struct chart * make_np_plot (const struct np *np, const struct casereader *reader, const char *label, bool detrended) { - struct np_plot_chart *npp; - if (np->n <= 1.0) return NULL; - npp = xzalloc (sizeof *npp); + struct np_plot_chart *npp = XZALLOC (struct np_plot_chart); chart_init (&npp->chart, &np_plot_chart_class, label); npp->data = casereader_clone (reader); npp->y_min = np->y_min; diff --git a/src/output/charts/scatterplot.c b/src/output/charts/scatterplot.c index 9c9c42a71e..5e8d27155e 100644 --- a/src/output/charts/scatterplot.c +++ b/src/output/charts/scatterplot.c @@ -37,9 +37,7 @@ scatterplot_create (struct casereader *reader, const char *label, double xmin, double xmax, double ymin, double ymax) { - struct scatterplot_chart *spc; - - spc = xzalloc (sizeof *spc); + struct scatterplot_chart *spc = XZALLOC (struct scatterplot_chart); chart_init (&spc->chart, &scatterplot_chart_class, label); spc->data = reader; diff --git a/src/output/charts/spreadlevel-plot.c b/src/output/charts/spreadlevel-plot.c index 5fd189d6e0..2d15e5430e 100644 --- a/src/output/charts/spreadlevel-plot.c +++ b/src/output/charts/spreadlevel-plot.c @@ -31,7 +31,7 @@ struct chart * spreadlevel_plot_create (const char *label, double tx_pwr) { - struct spreadlevel_plot_chart *sl = xzalloc (sizeof *sl); + struct spreadlevel_plot_chart *sl = XZALLOC (struct spreadlevel_plot_chart); chart_init (&sl->chart, &spreadlevel_plot_chart_class, label); sl->x_lower = DBL_MAX; diff --git a/src/output/csv.c b/src/output/csv.c index b1ad6b0c17..ba1481c9a0 100644 --- a/src/output/csv.c +++ b/src/output/csv.c @@ -77,10 +77,9 @@ csv_create (struct file_handle *fh, enum settings_output_devices device_type, struct string_map *o) { struct output_driver *d; - struct csv_driver *csv; char *quote; - csv = xzalloc (sizeof *csv); + struct csv_driver *csv = XZALLOC (struct csv_driver); d = &csv->driver; output_driver_init (&csv->driver, &csv_driver_class, fh_get_file_name (fh), device_type); diff --git a/src/output/driver.c b/src/output/driver.c index f40876449b..063ae9366b 100644 --- a/src/output/driver.c +++ b/src/output/driver.c @@ -91,7 +91,7 @@ put_strftime (const char *key, const char *format, void output_engine_push (void) { - struct output_engine *e = xzalloc (sizeof (*e)); + struct output_engine *e = XZALLOC (struct output_engine); llx_init (&e->drivers); diff --git a/src/output/html.c b/src/output/html.c index 60ca95e28d..0546e5d3a2 100644 --- a/src/output/html.c +++ b/src/output/html.c @@ -180,9 +180,7 @@ html_create (struct file_handle *fh, enum settings_output_devices device_type, struct string_map *o) { struct output_driver *d; - struct html_driver *html; - - html = xzalloc (sizeof *html); + struct html_driver *html = XZALLOC (struct html_driver); d = &html->driver; output_driver_init (&html->driver, &html_driver_class, fh_get_file_name (fh), device_type); diff --git a/src/output/msglog.c b/src/output/msglog.c index 7fe6555f19..20cfe3a3b2 100644 --- a/src/output/msglog.c +++ b/src/output/msglog.c @@ -57,7 +57,6 @@ struct output_driver * msglog_create (const char *file_name) { enum settings_output_devices type; - struct msglog_driver *ml; FILE *file; struct file_handle *handle = fh_create_file (NULL, file_name, NULL, fh_default_properties ()); @@ -73,7 +72,7 @@ msglog_create (const char *file_name) ? SETTINGS_DEVICE_TERMINAL : SETTINGS_DEVICE_UNFILTERED); - ml = xzalloc (sizeof *ml); + struct msglog_driver *ml = XZALLOC (struct msglog_driver); ml->handle = handle; output_driver_init (&ml->driver, &msglog_class, file_name, type); ml->file = file; diff --git a/src/output/odt.c b/src/output/odt.c index a96958b9e8..abb30cb530 100644 --- a/src/output/odt.c +++ b/src/output/odt.c @@ -285,7 +285,6 @@ odt_create (struct file_handle *fh, enum settings_output_devices device_type, struct string_map *o UNUSED) { struct output_driver *d; - struct odt_driver *odt; struct zip_writer *zip; const char *file_name = fh_get_file_name (fh); @@ -293,7 +292,7 @@ odt_create (struct file_handle *fh, enum settings_output_devices device_type, if (zip == NULL) return NULL; - odt = xzalloc (sizeof *odt); + struct odt_driver *odt = XZALLOC (struct odt_driver); d = &odt->driver; output_driver_init (d, &odt_driver_class, file_name, device_type); diff --git a/src/output/output-item.c b/src/output/output-item.c index 97f51f7604..0c60b8dc26 100644 --- a/src/output/output-item.c +++ b/src/output/output-item.c @@ -598,7 +598,7 @@ text_item_create_value (enum text_item_subtype subtype, ex->font_style->typeface = xstrdup ("Monospaced"); } - struct output_item *item = xzalloc (sizeof *item); + struct output_item *item = XZALLOC (struct output_item); *item = (struct output_item) { OUTPUT_ITEM_INITIALIZER (OUTPUT_ITEM_TEXT), .command_name = xstrdup_if_nonnull (output_get_command_name ()), diff --git a/src/output/pivot-table.c b/src/output/pivot-table.c index cc541646c8..6bb446ed8e 100644 --- a/src/output/pivot-table.c +++ b/src/output/pivot-table.c @@ -865,7 +865,7 @@ pivot_table_create (const char *title) struct pivot_table * pivot_table_create__ (struct pivot_value *title, const char *subtype) { - struct pivot_table *table = xzalloc (sizeof *table); + struct pivot_table *table = XZALLOC (struct pivot_table); table->ref_cnt = 1; table->show_title = true; table->show_caption = true; @@ -2818,7 +2818,7 @@ struct pivot_value * pivot_value_new_value (const union value *value, int width, const struct fmt_spec *format, const char *encoding) { - struct pivot_value *pv = xzalloc (sizeof *pv); + struct pivot_value *pv = XZALLOC (struct pivot_value); if (width > 0) { char *s = recode_string (UTF8, encoding, CHAR_CAST (char *, value->s), diff --git a/src/output/render.c b/src/output/render.c index 249d77f80b..b88f10badb 100644 --- a/src/output/render.c +++ b/src/output/render.c @@ -1976,7 +1976,7 @@ static struct render_overflow * insert_overflow (struct render_page_selection *s, const struct table_cell *cell) { - struct render_overflow *of = xzalloc (sizeof *of); + struct render_overflow *of = XZALLOC (struct render_overflow); cell_to_subpage (s, cell, of->d); hmap_insert (&s->subpage->overflows, &of->node, hash_cell (of->d[H], of->d[V])); diff --git a/src/output/spv-driver.c b/src/output/spv-driver.c index 1eb57f7f16..707e82abfa 100644 --- a/src/output/spv-driver.c +++ b/src/output/spv-driver.c @@ -52,9 +52,7 @@ spv_create (struct file_handle *fh, enum settings_output_devices device_type, struct string_map *o UNUSED) { struct output_driver *d; - struct spv_driver *spv; - - spv = xzalloc (sizeof *spv); + struct spv_driver *spv = XZALLOC (struct spv_driver); d = &spv->driver; spv->handle = fh; output_driver_init (&spv->driver, &spv_driver_class, fh_get_file_name (fh), diff --git a/src/output/spv/spv-legacy-decoder.c b/src/output/spv/spv-legacy-decoder.c index f5b50e2502..94d05b59f2 100644 --- a/src/output/spv/spv-legacy-decoder.c +++ b/src/output/spv/spv-legacy-decoder.c @@ -704,7 +704,7 @@ decode_label_frame (struct pivot_table *table, if (target) { - struct pivot_value *value = xzalloc (sizeof *value); + struct pivot_value *value = XZALLOC (struct pivot_value); value->type = PIVOT_VALUE_TEXT; for (size_t i = 0; i < lf->label->n_text; i++) { @@ -784,7 +784,7 @@ decode_spvdx_source_variable (const struct spvxml_node *node, "source %s variable %s.", sv->node_.id, sv->source, sv->source_name); - struct spv_series *s = xzalloc (sizeof *s); + struct spv_series *s = XZALLOC (struct spv_series); s->name = xstrdup (node->id); s->xml = node; s->label = xstrdup_if_nonnull (sv->label); @@ -869,7 +869,7 @@ decode_spvdx_derived_variable (const struct spvxml_node *node, return xasprintf ("Derived variable %s has unknown value \"%s\"", node->id, dv->value); - struct spv_series *s = xzalloc (sizeof *s); + struct spv_series *s = XZALLOC (struct spv_series); s->format = F_8_0; s->name = xstrdup (node->id); s->values = values; @@ -959,7 +959,7 @@ pivot_value_from_data_value (const struct spv_data_value *data, if (error) return error; - struct pivot_value *v = xzalloc (sizeof *v); + struct pivot_value *v = XZALLOC (struct pivot_value); if (data->width >= 0) { if (format && fmt_get_category (f.type) == FMT_CAT_DATE) @@ -1144,7 +1144,7 @@ add_dimension (struct spv_series **series, size_t n, assert (n_cats > 0); /* Make the categories. */ - struct pivot_dimension *d = xzalloc (sizeof *d); + struct pivot_dimension *d = XZALLOC (struct pivot_dimension); table->dimensions[table->n_dimensions++] = d; series[0]->n_index = max_cat + 1; @@ -1155,7 +1155,7 @@ add_dimension (struct spv_series **series, size_t n, { struct spv_data_value *dv = &series[0]->values[cat_rows[k]]; int dv_num = dv ? dv->d : dv->index; - struct pivot_category *cat = xzalloc (sizeof *cat); + struct pivot_category *cat = XZALLOC (struct pivot_category); char *retval = pivot_value_from_data_value ( spv_map_lookup (&series[0]->map, dv), NULL, NULL, &cat->name); if (retval) diff --git a/src/output/spv/spv-light-decoder.c b/src/output/spv/spv-light-decoder.c index e58d423d67..f1f3dba960 100644 --- a/src/output/spv/spv-light-decoder.c +++ b/src/output/spv/spv-light-decoder.c @@ -291,7 +291,7 @@ decode_spvlb_value (const struct pivot_table *table, { *outp = NULL; - struct pivot_value *out = xzalloc (sizeof *out); + struct pivot_value *out = XZALLOC (struct pivot_value); const struct spvlb_value_mod *vm; char *error; @@ -540,7 +540,7 @@ decode_spvlb_categories (const struct pivot_table *table, if (error) return error; - struct pivot_category *out = xzalloc (sizeof *out); + struct pivot_category *out = XZALLOC (struct pivot_category); out->name = name; out->parent = parent; out->dimension = dimension; @@ -629,7 +629,7 @@ decode_spvlb_dimension (const struct pivot_table *table, if (error) return error; - struct pivot_dimension *out = xzalloc (sizeof *out); + struct pivot_dimension *out = XZALLOC (struct pivot_dimension); out->level = UINT_MAX; out->top_index = idx; out->hide_all_labels = in->props->hide_all_labels; @@ -838,7 +838,7 @@ decode_spvlb_table (const struct spvlb_table *in, struct pivot_table **outp) in->header->version); char *error = NULL; - struct pivot_table *out = xzalloc (sizeof *out); + struct pivot_table *out = XZALLOC (struct pivot_table); out->ref_cnt = 1; hmap_init (&out->cells); out->look = pivot_table_look_new_builtin_default (); diff --git a/src/ui/gui/find-dialog.c b/src/ui/gui/find-dialog.c index 18f933decc..16f5e36576 100644 --- a/src/ui/gui/find-dialog.c +++ b/src/ui/gui/find-dialog.c @@ -597,7 +597,7 @@ regexp_destroy (struct comparator *cmptr) static struct comparator * numeric_comparator_create (const struct variable *var, const char *target) { - struct numeric_comparator *nc = xzalloc (sizeof (*nc)); + struct numeric_comparator *nc = XZALLOC (struct numeric_comparator); struct comparator *cmptr = &nc->parent; cmptr->flags = 0; @@ -617,7 +617,7 @@ static struct comparator * string_comparator_create (const struct variable *var, const char *target, enum string_cmp_flags flags) { - struct string_comparator *ssc = xzalloc (sizeof (*ssc)); + struct string_comparator *ssc = XZALLOC (struct string_comparator); struct comparator *cmptr = &ssc->parent; cmptr->flags = flags; @@ -639,7 +639,7 @@ regexp_comparator_create (const struct variable *var, const char *target, enum string_cmp_flags flags) { int code; - struct regexp_comparator *rec = xzalloc (sizeof (*rec)); + struct regexp_comparator *rec = XZALLOC (struct regexp_comparator); struct comparator *cmptr = &rec->parent; cmptr->flags = flags; diff --git a/src/ui/gui/psppire-import-textfile.c b/src/ui/gui/psppire-import-textfile.c index 5ef83fcd2a..eedc21a082 100644 --- a/src/ui/gui/psppire-import-textfile.c +++ b/src/ui/gui/psppire-import-textfile.c @@ -120,7 +120,7 @@ choose_likely_separators (PsppireImportAssistant *ia) if (cn == NULL) { - struct separator_count_node *new_cn = xzalloc (sizeof *new_cn); + struct separator_count_node *new_cn = XZALLOC (struct separator_count_node); new_cn->occurance = counts[j]; new_cn->quantity = 1; hmap_insert (&count_map[j], &new_cn->node, hash); diff --git a/src/ui/gui/psppire-output-window.c b/src/ui/gui/psppire-output-window.c index 7a60cce356..46535b0f23 100644 --- a/src/ui/gui/psppire-output-window.c +++ b/src/ui/gui/psppire-output-window.c @@ -166,10 +166,9 @@ static struct output_driver_class psppire_output_class = void psppire_output_window_setup (void) { - struct psppire_output_driver *pod; + struct psppire_output_driver *pod = XZALLOC (struct psppire_output_driver); struct output_driver *d; - pod = xzalloc (sizeof *pod); d = &pod->driver; output_driver_init (d, &psppire_output_class, "PSPPIRE", SETTINGS_DEVICE_UNFILTERED); diff --git a/src/ui/terminal/terminal-opts.c b/src/ui/terminal/terminal-opts.c index 5a6a8fbd23..b9d9e50c58 100644 --- a/src/ui/terminal/terminal-opts.c +++ b/src/ui/terminal/terminal-opts.c @@ -263,13 +263,11 @@ terminal_opts_init (struct argv_parser *ap, enum segmenter_mode *syntax_mode, bool *process_statrc, char **syntax_encoding) { - struct terminal_opts *to; - *syntax_mode = SEG_MODE_AUTO; *process_statrc = true; *syntax_encoding = "Auto"; - to = xzalloc (sizeof *to); + struct terminal_opts *to = XZALLOC (struct terminal_opts); to->syntax_mode = syntax_mode; string_map_init (&to->options); to->has_output_driver = false; diff --git a/src/ui/terminal/terminal-reader.c b/src/ui/terminal/terminal-reader.c index e418ec7e08..3225678e87 100644 --- a/src/ui/terminal/terminal-reader.c +++ b/src/ui/terminal/terminal-reader.c @@ -189,12 +189,10 @@ static struct lex_reader_class terminal_reader_class = struct lex_reader * terminal_reader_create (void) { - struct terminal_reader *r; - if (!n_terminal_readers++) readline_init (); - r = xzalloc (sizeof *r); + struct terminal_reader *r = XZALLOC (struct terminal_reader); r->reader.class = &terminal_reader_class; r->reader.syntax = SEG_MODE_INTERACTIVE; r->reader.error = LEX_ERROR_TERMINAL; -- 2.30.2