Substituted strncmp for strcmp to limit string size
[pspp-builds.git] / src / examine.q
index 7f5396a47169199fc0de8399a0673905ce54343f..43ecc13037d3d6a2faf3ab0ae762a08cd78022ae 100644 (file)
@@ -233,6 +233,7 @@ cmd_examine(void)
        hsh_destroy ( ff->fstats ) ;
        free ( ff ) ;
       }
+    factors = 0;
   }
 
   subc_list_double_destroy(&percentile_list);
@@ -394,7 +395,7 @@ list_to_ptile_hash(const subc_list_double *l)
 
   for ( i = 0 ; i < subc_list_double_count(l) ; ++i )
     {
-      struct percentile *p = xmalloc (sizeof (struct percentile));
+      struct percentile *p = xmalloc (sizeof *p);
       
       p->p = subc_list_double_at(l,i);
       p->v = SYSMIS;
@@ -511,7 +512,7 @@ xmn_custom_variables(struct cmd_examine *cmd )
 
   assert(n_dependent_vars);
 
-  totals = xmalloc( sizeof(struct metrics) * n_dependent_vars);
+  totals = xnmalloc (n_dependent_vars, sizeof *totals);
 
   if ( lex_match(T_BY))
     {
@@ -534,7 +535,7 @@ static int
 examine_parse_independent_vars(struct cmd_examine *cmd)
 {
   int success;
-  struct factor *sf = xmalloc(sizeof(struct factor));
+  struct factor *sf = xmalloc (sizeof *sf);
 
   if ((token != T_ID || dict_lookup_var (default_dict, tokid) == NULL)
       && token != T_ALL)
@@ -663,9 +664,6 @@ factor_calc(struct ccase *c, int case_no, double weight, int case_missing)
 
 }
 
-
-
-
 static void 
 run_examine(const struct casefile *cf, void *cmd_ )
 {
@@ -677,7 +675,6 @@ run_examine(const struct casefile *cf, void *cmd_ )
 
   /* Make sure we haven't got rubbish left over from a 
      previous split */
-
   struct factor *fctr = factors;
   while (fctr) 
     {
@@ -1858,7 +1855,7 @@ np_plot(const struct metrics *m, const char *factorname)
   {
     /* We have to cache the detrended data, beacause we need to 
        find its limits before we can plot it */
-    double *d_data = xmalloc (m->n_data * sizeof(double));
+    double *d_data = xnmalloc (m->n_data, sizeof *d_data);
     double d_max = -DBL_MAX;
     double d_min = DBL_MAX;
     for ( i = 0 ; i < m->n_data; ++i )