Fix up potential overflows in size calculations by replacing
[pspp] / src / cat.h
index 80c31794836fe996e1b02a580ec2d2902ed31b27..593a5764907a644c52a8a1ce8a39b02839e046c9 100644 (file)
--- a/src/cat.h
+++ b/src/cat.h
 struct recoded_categorical
 {
   const struct variable *v;    /* Original variable. */
-  union value **vals;
-  gsl_matrix *m;               /* Vector-encoded values of the original
-                                  variable. The ith row of the matrix corresponds
-                                  to the ith value of a categorical variable.
+  union value *vals;
+  gsl_matrix *m;               /* Vector-encoded values of the
+                                  original variable. The ith row of
+                                  the matrix corresponds to the ith
+                                  value of a categorical variable.
                                 */
   size_t n_categories;
   size_t first_column;         /* First column of the gsl_matrix which
@@ -58,21 +59,23 @@ struct recoded_categorical
                                   variable.
                                 */
   size_t last_column;          /* Last column containing the recoded
-                                  categories.  The practice of keeping only the
-                                  first and last columns of the matrix implies
-                                  those columns corresponding to v must be
+                                  categories.  The practice of
+                                  keeping only the first and last
+                                  columns of the matrix implies those
+                                  columns corresponding to v must be
                                   contiguous.
                                 */
-  size_t n_allocated_categories;       /* This is used only during initialization
-                                          to keep track of the number of values
-                                          stored. 
-                                        */
+  size_t n_allocated_categories; /* This is used only during
+                                   initialization to keep
+                                   track of the number of
+                                   values stored.
+                                */
 };
 
 /*
   There are usually multiple categorical variables to recode.  Get rid
-  of this immediately once the variable structure has been modified to
-  contain the binary encoding.
+  of this structure immediately when the variable structure has been
+  modified to contain the binary encoding.
  */
 struct recoded_categorical_array
 {
@@ -96,7 +99,7 @@ struct design_matrix_var
                                   in the variable's struct recoded_categorical.
                                 */
   int last_column;
-  struct variable *v;
+  const struct variable *v;
 };
 struct design_matrix
 {
@@ -115,11 +118,8 @@ struct design_matrix
                                         */
   size_t n_vars;
 };
-const union value *cr_vector_to_value (const gsl_vector *,
-                                      struct recoded_categorical *);
-
-gsl_vector_const_view cr_value_to_vector (const union value *,
-                                         struct recoded_categorical *);
+union value *cr_vector_to_value (const gsl_vector *,
+                                struct recoded_categorical *);
 
 void cr_value_update (struct recoded_categorical *, const union value *);
 
@@ -158,8 +158,8 @@ void design_matrix_set_numeric (struct design_matrix *, size_t,
 size_t design_matrix_var_to_column (const struct design_matrix *,
                                    const struct variable *);
 
-const struct variable *design_matrix_col_to_var (const struct design_matrix *,
-                                                size_t);
+struct variable *design_matrix_col_to_var (const struct design_matrix *,
+                                          size_t);
 
 void
 design_matrix_set (struct design_matrix *, size_t,