added automake.mk files in src/language
[pspp] / src / descript.c
index 1e52abf6e3f6d525c2a1854c91c833f887ed07f6..a7152301abfdfcfcefb93af2dfea68b6d1b3205f 100644 (file)
@@ -68,7 +68,6 @@ struct dsc_z_score
 /* DESCRIPTIVES transformation (for calculating Z-scores). */
 struct dsc_trns
   {
-    struct trns_header h;
     struct dsc_z_score *z_scores; /* Array of Z-scores. */
     int z_score_cnt;            /* Number of Z-scores. */
     struct variable **vars;     /* Variables for listwise missing checks. */
@@ -311,7 +310,7 @@ cmd_descriptives (void)
                                     PV_APPEND | PV_NO_DUPLICATE | PV_NUMERIC))
                goto error;
 
-              dsc->vars = xrealloc (dsc->vars, sizeof *dsc->vars * var_cnt);
+              dsc->vars = xnrealloc (dsc->vars, var_cnt, sizeof *dsc->vars);
               for (i = dsc->var_cnt; i < var_cnt; i++)
                 {
                   struct dsc_var *dv = &dsc->vars[i];
@@ -569,10 +568,10 @@ dump_z_table (struct dsc_proc *dsc)
    (either system or user-missing values that weren't included).
 */
 static int
-descriptives_trns_proc (struct trns_header *trns, struct ccase * c,
+descriptives_trns_proc (void *trns_, struct ccase * c,
                         int case_idx UNUSED)
 {
-  struct dsc_trns *t = (struct dsc_trns *) trns;
+  struct dsc_trns *t = trns_;
   struct dsc_z_score *z;
   struct variable **vars;
   int all_sysmis = 0;
@@ -611,9 +610,9 @@ descriptives_trns_proc (struct trns_header *trns, struct ccase * c,
 
 /* Frees a descriptives_trns struct. */
 static void
-descriptives_trns_free (struct trns_header * trns)
+descriptives_trns_free (void *trns_)
 {
-  struct dsc_trns *t = (struct dsc_trns *) trns;
+  struct dsc_trns *t = trns_;
 
   free (t->z_scores);
   assert((t->missing_type != DSC_LISTWISE) ^ (t->vars != NULL));
@@ -632,16 +631,14 @@ setup_z_trns (struct dsc_proc *dsc)
       cnt++;
 
   t = xmalloc (sizeof *t);
-  t->h.proc = descriptives_trns_proc;
-  t->h.free = descriptives_trns_free;
-  t->z_scores = xmalloc (cnt * sizeof *t->z_scores);
+  t->z_scores = xnmalloc (cnt, sizeof *t->z_scores);
   t->z_score_cnt = cnt;
   t->missing_type = dsc->missing_type;
   t->include_user_missing = dsc->include_user_missing;
   if ( t->missing_type == DSC_LISTWISE )
     {
       t->var_cnt = dsc->var_cnt;
-      t->vars = xmalloc(t->var_cnt * sizeof *t->vars);
+      t->vars = xnmalloc (t->var_cnt, sizeof *t->vars);
       for (i = 0; i < t->var_cnt; i++)
        t->vars[i] = dsc->vars[i].v;
     }
@@ -650,7 +647,6 @@ setup_z_trns (struct dsc_proc *dsc)
       t->var_cnt = 0;
       t->vars = NULL;
     }
-  
 
   for (cnt = i = 0; i < dsc->var_cnt; i++)
     {
@@ -685,7 +681,7 @@ setup_z_trns (struct dsc_proc *dsc)
        }
     }
 
-  add_transformation ((struct trns_header *) t);
+  add_transformation (descriptives_trns_proc, descriptives_trns_free, t);
 }
 \f
 /* Statistical calculation. */