Barchart.c: Change type of flag from int to bool
[pspp] / src / output / charts / barchart.c
index 07a39e818f65193b6ddc6ed4816eab19c3a65dd5..fea50b787e2fe6315bf35243567d09a43ff0d8c6 100644 (file)
@@ -136,8 +136,9 @@ barchart_create (const struct variable **var, int n_vars,
            {
              struct category *s = xzalloc (sizeof *s);
              s->idx = idx++;
-             value_init (&s->val, var_get_width (var[pidx]));
-             value_copy (&s->val, &src->values[pidx], var_get_width (var[pidx]));
+             s->width = var_get_width (var[pidx]);
+             value_init (&s->val, s->width);
+             value_copy (&s->val, &src->values[pidx], s->width);
              ds_init_empty (&s->label);
              var_append_value_name (var[pidx], &s->val, &s->label);
 
@@ -173,7 +174,8 @@ barchart_create (const struct variable **var, int n_vars,
            {
              struct category *s = xzalloc (sizeof *s);
              s->idx = idx++;
-             value_init (&s->val, var_get_width (var[sidx]));
+             s->width = var_get_width (var[sidx]);
+             value_init (&s->val, s->width);
              value_copy (&s->val, &src->values[sidx], var_get_width (var[sidx]));
              ds_init_empty (&s->label);
              var_append_value_name (var[sidx], &s->val, &s->label);
@@ -211,7 +213,7 @@ barchart_create (const struct variable **var, int n_vars,
        struct freq *c = cats[i];
 
        struct freq *foo;
-       int flag = 0;
+       bool flag = false;
        size_t hash = hash_freq_2level_ptr (&c, bar);
        HMAP_FOR_EACH_WITH_HASH (foo, struct freq, node, hash, &level2table)
          {
@@ -222,7 +224,7 @@ barchart_create (const struct variable **var, int n_vars,
                if (foo->count > bar->largest)
                  bar->largest = foo->count;
                
-               flag = 1;
+               flag = true;
                break;
              }
          }
@@ -256,6 +258,8 @@ destroy_cat_map (struct hmap *m)
   struct category *next = NULL;
   HMAP_FOR_EACH_SAFE (foo, next, struct category, node, m)
     {
+      value_destroy (&foo->val, foo->width);
+
       ds_destroy (&foo->label);
       free (foo);
     }