Replace numerous instances of xzalloc with XZALLOC
[pspp] / src / data / dictionary.c
index 3902f4ced52545155343aba26167afeacdc22d5d..ab4642a4da493c536b499a60e71479cbb14f7670 100644 (file)
@@ -250,7 +250,7 @@ dict_copy_callbacks (struct dictionary *dest,
 struct dictionary *
 dict_create (const char *encoding)
 {
-  struct dictionary *d = xzalloc (sizeof *d);
+  struct dictionary *d = XZALLOC (struct dictionary);
 
   d->encoding = xstrdup (encoding);
   d->names_must_be_ids = true;
@@ -1094,6 +1094,9 @@ make_hinted_name (const struct dictionary *dict, const char *hint)
   size_t ofs;
   int mblen;
 
+  if (hint_len > ID_MAX_LEN)
+    hint_len = ID_MAX_LEN;
+
   /* The allocation size here is OK: characters that are copied directly fit
      OK, and characters that are not copied directly are replaced by a single
      '_' byte.  If u8_mbtouc() replaces bad input by 0xfffd, then that will get
@@ -1200,6 +1203,7 @@ dict_make_unique_var_name (const struct dictionary *dict, const char *hint,
       if (hinted_name != NULL)
         return hinted_name;
     }
+
   return make_numeric_name (dict, num_start);
 }
 
@@ -1795,6 +1799,9 @@ dict_var_changed (const struct variable *v, unsigned int what, struct variable *
       if (NULL == d)
        return;
 
+      if (what & (VAR_TRAIT_WIDTH | VAR_TRAIT_POSITION))
+        invalidate_proto (d);
+
       if (d->changed) d->changed (d, d->changed_data);
       if (d->callbacks && d->callbacks->var_changed)
         d->callbacks->var_changed (d, var_get_dict_index (v), what, oldvar, d->cb_data);