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 |
|
|
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 |
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 |
|
|
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; |
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 |
{ |
{ |