X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fcat.c;h=0dd9a014ad5cde729d7629ff1b975a9c6324fa21;hb=4aa81a07a03b3322e3bcf2ce141fe119c02f87f7;hp=afdb44ef7253216dee4c67017af8d763ed7ad0a5;hpb=86968643348c6479634a89929a3094df5ec5f8b1;p=pspp diff --git a/src/cat.c b/src/cat.c index afdb44ef72..0dd9a014ad 100644 --- a/src/cat.c +++ b/src/cat.c @@ -65,7 +65,7 @@ cr_recoded_categorical_create (const struct variable *v) rc->v = v; rc->n_categories = 0; rc->n_allocated_categories = N_INITIAL_CATEGORIES; - rc->vals = xmalloc (N_INITIAL_CATEGORIES * sizeof (*rc->vals)); + rc->vals = xnmalloc (N_INITIAL_CATEGORIES, sizeof *rc->vals); return rc; } @@ -85,7 +85,7 @@ cr_recoded_cat_ar_create (int n_variables, struct variable *v_variables[]) struct recoded_categorical_array *ca; struct variable *v; - ca = (struct recoded_categorical_array *) xmalloc (sizeof (*ca)); + ca = xmalloc (sizeof *ca); for (i = 0; i < n_variables; i++) { v = v_variables[i]; @@ -95,7 +95,7 @@ cr_recoded_cat_ar_create (int n_variables, struct variable *v_variables[]) } } ca->n_vars = n_categoricals; - ca->a = xmalloc (n_categoricals * sizeof (*(ca->a))); + ca->a = xnmalloc (n_categoricals, sizeof *ca->a); for (i = 0; i < n_categoricals; i++) { *(ca->a + i) = cr_recoded_categorical_create (v_variables[i]); @@ -145,8 +145,8 @@ cr_value_update (struct recoded_categorical *rc, const union value *v) if (rc->n_categories >= rc->n_allocated_categories) { rc->n_allocated_categories *= 2; - rc->vals = xrealloc (rc->vals, rc->n_allocated_categories - * sizeof (*(rc->vals))); + rc->vals = xnrealloc (rc->vals, + rc->n_allocated_categories, sizeof *rc->vals); } rc->vals[rc->n_categories] = *v; rc->n_categories++; @@ -319,8 +319,8 @@ design_matrix_create (int n_variables, size_t n_cols = 0; size_t col; - dm = xmalloc (sizeof (*dm)); - dm->vars = xmalloc (n_variables * sizeof (struct variable *)); + dm = xmalloc (sizeof *dm); + dm->vars = xnmalloc (n_variables, sizeof *dm->vars); dm->n_vars = n_variables; for (i = 0; i < n_variables; i++) @@ -341,7 +341,7 @@ design_matrix_create (int n_variables, } } dm->m = gsl_matrix_calloc (n_data, n_cols); - dm->vars = xmalloc (dm->n_vars * sizeof (*(dm->vars))); + dm->vars = xnmalloc (dm->n_vars, sizeof *dm->vars); assert (dm->vars != NULL); col = 0; @@ -354,6 +354,7 @@ design_matrix_create (int n_variables, tmp = &(dm->vars[col]); tmp->v = v; tmp->first_column = col; + tmp->last_column = col; col++; } else if (v->type == ALPHA) @@ -399,7 +400,7 @@ design_matrix_col_to_var_index (const struct design_matrix *dm, size_t col) /* Return a pointer to the variable whose values - are stored in column col. + are stored in column col. BUG IN HERE */ struct variable * design_matrix_col_to_var (const struct design_matrix *dm, size_t col)