+
+
+ /* Deep copy. Not necessary for cmd line, but essential for the GUI,
+ since an expose callback will access these structs which may not
+ exist.
+ */
+ bar->cats = xcalloc (n_cats, sizeof *bar->cats);
+
+ bar->widths[0] = var_get_width (bar->var[0]);
+ if (n_vars > 1)
+ bar->widths[1] = var_get_width (bar->var[1]);
+
+ {
+ struct hmap level2table;
+ hmap_init (&level2table);
+ int x = 0;
+
+ for (i = 0; i < n_cats; i++)
+ {
+ struct freq *c = cats[i];
+
+ struct freq *foo;
+ bool flag = false;
+ size_t hash = hash_freq_2level_ptr (&c, bar);
+ HMAP_FOR_EACH_WITH_HASH (foo, struct freq, node, hash, &level2table)
+ {
+ if (0 == compare_freq_2level_ptr_3way (&foo, &c, bar))
+ {
+ foo->count += c->count;
+ bar->total_count += c->count;
+
+ if (foo->count > bar->largest)
+ bar->largest = foo->count;
+
+ flag = true;
+ break;
+ }
+ }
+
+ if (!flag)
+ {
+ struct freq *aggregated_freq = freq_clone (c, n_vars, bar->widths);
+ hmap_insert (&level2table, &aggregated_freq->node, hash);
+
+ if (c->count > bar->largest)
+ bar->largest = aggregated_freq->count;
+
+ bar->total_count += c->count;
+ bar->cats[x++] = aggregated_freq;
+ }
+ }
+
+ bar->n_nzcats = hmap_count (&level2table);
+ hmap_destroy (&level2table);
+ }
+
+ sort (bar->cats, bar->n_nzcats, sizeof *bar->cats,
+ compare_freq_2level_ptr_3way, bar);
+