/[pspp]/pspp/src/cat.c
ViewVC logotype

Diff of /pspp/src/cat.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by jstover, Thu Oct 13 19:58:54 2005 UTC revision 1.5 by blp, Wed Oct 26 05:06:14 2005 UTC
# Line 65  cr_recoded_categorical_create (const str Line 65  cr_recoded_categorical_create (const str
65    rc->v = v;    rc->v = v;
66    rc->n_categories = 0;    rc->n_categories = 0;
67    rc->n_allocated_categories = N_INITIAL_CATEGORIES;    rc->n_allocated_categories = N_INITIAL_CATEGORIES;
68    rc->vals = xmalloc (N_INITIAL_CATEGORIES * sizeof (*rc->vals));    rc->vals = xnmalloc (N_INITIAL_CATEGORIES, sizeof *rc->vals);
69    
70    return rc;    return rc;
71  }  }
# Line 85  cr_recoded_cat_ar_create (int n_variable Line 85  cr_recoded_cat_ar_create (int n_variable
85    struct recoded_categorical_array *ca;    struct recoded_categorical_array *ca;
86    struct variable *v;    struct variable *v;
87    
88    ca = (struct recoded_categorical_array *) xmalloc (sizeof (*ca));    ca = xmalloc (sizeof *ca);
89    for (i = 0; i < n_variables; i++)    for (i = 0; i < n_variables; i++)
90      {      {
91        v = v_variables[i];        v = v_variables[i];
# Line 95  cr_recoded_cat_ar_create (int n_variable Line 95  cr_recoded_cat_ar_create (int n_variable
95          }          }
96      }      }
97    ca->n_vars = n_categoricals;    ca->n_vars = n_categoricals;
98    ca->a = xmalloc (n_categoricals * sizeof (*(ca->a)));    ca->a = xnmalloc (n_categoricals, sizeof *ca->a);
99    for (i = 0; i < n_categoricals; i++)    for (i = 0; i < n_categoricals; i++)
100      {      {
101        *(ca->a + i) = cr_recoded_categorical_create (v_variables[i]);        *(ca->a + i) = cr_recoded_categorical_create (v_variables[i]);
# Line 145  cr_value_update (struct recoded_categori Line 145  cr_value_update (struct recoded_categori
145        if (rc->n_categories >= rc->n_allocated_categories)        if (rc->n_categories >= rc->n_allocated_categories)
146          {          {
147            rc->n_allocated_categories *= 2;            rc->n_allocated_categories *= 2;
148            rc->vals = xrealloc (rc->vals, rc->n_allocated_categories            rc->vals = xnrealloc (rc->vals,
149                                 * sizeof (*(rc->vals)));                                  rc->n_allocated_categories, sizeof *rc->vals);
150          }          }
151        rc->vals[rc->n_categories] = *v;        rc->vals[rc->n_categories] = *v;
152        rc->n_categories++;        rc->n_categories++;
# Line 319  design_matrix_create (int n_variables, Line 319  design_matrix_create (int n_variables,
319    size_t n_cols = 0;    size_t n_cols = 0;
320    size_t col;    size_t col;
321    
322    dm = xmalloc (sizeof (*dm));    dm = xmalloc (sizeof *dm);
323    dm->vars = xmalloc (n_variables * sizeof (struct variable *));    dm->vars = xnmalloc (n_variables, sizeof *dm->vars);
324    dm->n_vars = n_variables;    dm->n_vars = n_variables;
325    
326    for (i = 0; i < n_variables; i++)    for (i = 0; i < n_variables; i++)
# Line 341  design_matrix_create (int n_variables, Line 341  design_matrix_create (int n_variables,
341          }          }
342      }      }
343    dm->m = gsl_matrix_calloc (n_data, n_cols);    dm->m = gsl_matrix_calloc (n_data, n_cols);
344    dm->vars = xmalloc (dm->n_vars * sizeof (*(dm->vars)));    dm->vars = xnmalloc (dm->n_vars, sizeof *dm->vars);
345    assert (dm->vars != NULL);    assert (dm->vars != NULL);
346    col = 0;    col = 0;
347    

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26