X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fget.c;h=e47850c364919c2d4d01481112a443ab1f8b9da2;hb=e210b20bf6f405637c8c03dd280b5a4a627191b8;hp=debc85b71c61cf10c0819a521e9a48177c11319b;hpb=c9e2bf6cb988f8c00d89ccf191a28388cccbd868;p=pspp diff --git a/src/get.c b/src/get.c index debc85b71c..e47850c364 100644 --- a/src/get.c +++ b/src/get.c @@ -383,6 +383,8 @@ parse_write_command (enum writer_type writer_type, aw->writer = pfm_open_writer (handle, dict, porfile_opts); break; } + + dict_destroy (dict); return aw; @@ -465,7 +467,6 @@ cmd_export (void) /* Transformation. */ struct output_trns { - struct trns_header h; /* Header. */ struct any_writer *aw; /* Writer. */ }; @@ -477,8 +478,6 @@ static int parse_output_trns (enum writer_type writer_type) { struct output_trns *t = xmalloc (sizeof *t); - t->h.proc = output_trns_proc; - t->h.free = output_trns_free; t->aw = parse_write_command (writer_type, XFORM_CMD, NULL); if (t->aw == NULL) { @@ -486,24 +485,24 @@ parse_output_trns (enum writer_type writer_type) return CMD_FAILURE; } - add_transformation (&t->h); + add_transformation (output_trns_proc, output_trns_free, t); return CMD_SUCCESS; } /* Writes case C to the system file specified on XSAVE or XEXPORT. */ static int -output_trns_proc (struct trns_header *h, struct ccase *c, int case_num UNUSED) +output_trns_proc (void *trns_, struct ccase *c, int case_num UNUSED) { - struct output_trns *t = (struct output_trns *) h; + struct output_trns *t = trns_; any_writer_write_case (t->aw, c); return -1; } /* Frees an XSAVE or XEXPORT transformation. */ static void -output_trns_free (struct trns_header *h) +output_trns_free (void *trns_) { - struct output_trns *t = (struct output_trns *) h; + struct output_trns *t = trns_; if (t != NULL) { @@ -559,13 +558,13 @@ parse_dict_trim (struct dictionary *dict) static bool rename_variables (struct dictionary *dict) { - int i; + size_t i; int success = 0; struct variable **v; char **new_names; - int nv, nn; + size_t nv, nn; char *err_name; int group; @@ -602,7 +601,7 @@ rename_variables (struct dictionary *dict) group = 1; while (lex_match ('(')) { - int old_nv = nv; + size_t old_nv = nv; if (!parse_variables (dict, &v, &nv, PV_NO_DUPLICATE | PV_APPEND)) goto done; @@ -618,7 +617,7 @@ rename_variables (struct dictionary *dict) msg (SE, _("Number of variables on left side of `=' (%d) does not " "match number of variables on right side (%d), in " "parenthesized group %d of RENAME subcommand."), - nv - old_nv, nn - old_nv, group); + (unsigned) (nv - old_nv), (unsigned) (nn - old_nv), group); goto done; } if (!lex_force_match (')')) @@ -648,7 +647,7 @@ static bool drop_variables (struct dictionary *dict) { struct variable **v; - int nv; + size_t nv; lex_match ('='); if (!parse_variables (dict, &v, &nv, PV_NONE)) @@ -670,8 +669,8 @@ static bool keep_variables (struct dictionary *dict) { struct variable **v; - int nv; - int i; + size_t nv; + size_t i; lex_match ('='); if (!parse_variables (dict, &v, &nv, PV_NONE)) @@ -681,7 +680,7 @@ keep_variables (struct dictionary *dict) dict_reorder_vars (dict, v, nv); /* Delete the remaining variables. */ - v = xrealloc (v, (dict_get_var_cnt (dict) - nv) * sizeof *v); + v = xnrealloc (v, dict_get_var_cnt (dict) - nv, sizeof *v); for (i = nv; i < dict_get_var_cnt (dict); i++) v[i - nv] = dict_get_var (dict, i); dict_delete_vars (dict, v, dict_get_var_cnt (dict) - nv); @@ -726,7 +725,7 @@ struct mtf_proc struct mtf_file *head; /* First file mentioned on FILE or TABLE. */ struct mtf_file *tail; /* Last file mentioned on FILE or TABLE. */ - int by_cnt; /* Number of variables on BY subcommand. */ + size_t by_cnt; /* Number of variables on BY subcommand. */ /* Names of FIRST, LAST variables. */ char first[LONG_NAME_LEN + 1], last[LONG_NAME_LEN + 1]; @@ -919,9 +918,9 @@ cmd_match_files (void) for (iter = mtf.head; iter != NULL; iter = iter->next) { - int i; + size_t i; - iter->by = xmalloc (sizeof *iter->by * mtf.by_cnt); + iter->by = xnmalloc (mtf.by_cnt, sizeof *iter->by); for (i = 0; i < mtf.by_cnt; i++) { @@ -1714,7 +1713,7 @@ finish_case_map (struct dictionary *d) map = xmalloc (sizeof *map); map->value_cnt = dict_get_next_value_idx (d); - map->map = xmalloc (sizeof *map->map * map->value_cnt); + map->map = xnmalloc (map->value_cnt, sizeof *map->map); for (i = 0; i < map->value_cnt; i++) map->map[i] = -1;