/[pspp]/pspp/src/sfm-read.c
ViewVC logotype

Diff of /pspp/src/sfm-read.c

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

revision 1.26 by blp, Tue Oct 25 04:28:17 2005 UTC revision 1.27 by blp, Wed Oct 26 05:06:14 2005 UTC
# Line 758  read_variables (struct sfm_reader *r, Line 758  read_variables (struct sfm_reader *r,
758    *var_by_idx = 0;    *var_by_idx = 0;
759    
760    /* Pre-allocate variables. */    /* Pre-allocate variables. */
761    if ( r->value_cnt != -1 )    if (r->value_cnt != -1)
762      {      {
763        *var_by_idx = xmalloc(r->value_cnt * sizeof (**var_by_idx));        *var_by_idx = xnmalloc (r->value_cnt, sizeof **var_by_idx);
764        r->vars = xmalloc( r->value_cnt * sizeof (*r->vars) );        r->vars = xnmalloc (r->value_cnt, sizeof *r->vars);
765      }      }
766    
767    
# Line 799  read_variables (struct sfm_reader *r, Line 799  read_variables (struct sfm_reader *r,
799    
800        if ( -1 == r->value_cnt )        if ( -1 == r->value_cnt )
801          {          {
802            *var_by_idx = xrealloc (*var_by_idx, sizeof **var_by_idx * (i + 1));            *var_by_idx = xnrealloc (*var_by_idx, i + 1, sizeof **var_by_idx);
803            r->vars = xrealloc(r->vars,  (i + 1) * sizeof (*r->vars) );            r->vars = xnrealloc (r->vars, i + 1, sizeof *r->vars);
804          }          }
805    
806        /* If there was a long string previously, make sure that the        /* If there was a long string previously, make sure that the
# Line 1066  read_value_labels (struct sfm_reader *r, Line 1066  read_value_labels (struct sfm_reader *r,
1066      }      }
1067    
1068    /* Allocate memory. */    /* Allocate memory. */
1069    labels = xcalloc (n_labels ,  sizeof *labels);    labels = xcalloc (n_labels, sizeof *labels);
1070    for (i = 0; i < n_labels; i++)    for (i = 0; i < n_labels; i++)
1071      labels[i].label = NULL;      labels[i].label = NULL;
1072    
# Line 1118  read_value_labels (struct sfm_reader *r, Line 1118  read_value_labels (struct sfm_reader *r,
1118             handle_get_filename (r->fh), n_vars, dict_get_var_cnt (dict)));             handle_get_filename (r->fh), n_vars, dict_get_var_cnt (dict)));
1119    
1120    /* Read the list of variables. */    /* Read the list of variables. */
1121    var = xmalloc (n_vars * sizeof *var);    var = xnmalloc (n_vars, sizeof *var);
1122    for (i = 0; i < n_vars; i++)    for (i = 0; i < n_vars; i++)
1123      {      {
1124        int32 var_idx;        int32 var_idx;
# Line 1306  buffer_input (struct sfm_reader *r) Line 1306  buffer_input (struct sfm_reader *r)
1306    size_t amt;    size_t amt;
1307    
1308    if (r->buf == NULL)    if (r->buf == NULL)
1309      r->buf = xmalloc (sizeof *r->buf * 128);      r->buf = xnmalloc (128, sizeof *r->buf);
1310    amt = fread (r->buf, sizeof *r->buf, 128, r->file);    amt = fread (r->buf, sizeof *r->buf, 128, r->file);
1311    if (ferror (r->file))    if (ferror (r->file))
1312      {      {

Legend:
Removed from v.1.26  
changed lines
  Added in v.1.27

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