- assert (vls != NULL);
-
- hsh_destroy (vls->labels);
- vls->labels = NULL;
-}
-
-/* Returns the number of value labels in VLS. */
-size_t
-val_labs_count (const struct val_labs *vls)
-{
- assert (vls != NULL);
-
- if (vls->labels == NULL)
- return 0;
- else
- return hsh_count (vls->labels);
-}
-\f
-/* One value label in internal format. */
-struct int_val_lab
- {
- union value value; /* The value being labeled. */
- struct atom *label; /* A ref-counted string. */
- };
-
-/* Creates and returns an int_val_lab based on VALUE and
- LABEL. */
-static struct int_val_lab *
-create_int_val_lab (struct val_labs *vls, union value value, const char *label)
-{
- struct int_val_lab *ivl;
-
- assert (label != NULL);
- assert (vls->width <= MAX_SHORT_STRING);
-
- ivl = xmalloc (sizeof *ivl);
- ivl->value = value;
- if (vls->width > 0)
- memset (ivl->value.s + vls->width, ' ', MAX_SHORT_STRING - vls->width);
- ivl->label = atom_create (label);
-
- return ivl;
-}
-
-/* If VLS does not already contain a value label for VALUE, adds
- LABEL for it and returns nonzero. Otherwise, returns zero.
- Behavior is undefined if VLS's width is greater than
- MAX_SHORT_STRING. */
-int
-val_labs_add (struct val_labs *vls, union value value, const char *label)
-{
- struct int_val_lab *ivl;
- void **vlpp;
-
- assert (vls != NULL);
- assert (vls->width <= MAX_SHORT_STRING);
- assert (label != NULL);
-
- if (vls->labels == NULL)
- vls->labels = hsh_create (8, compare_int_val_lab, hash_int_val_lab,
- free_int_val_lab, vls);
-
- ivl = create_int_val_lab (vls, value, label);
- vlpp = hsh_probe (vls->labels, ivl);
- if (*vlpp == NULL)
- {
- *vlpp = ivl;
- return 1;
- }
- else