2222 * nobjs : number of objectives, also the number of columns.
2323 */
2424int
25- read_objective_t_data (const char * filename , objective_t * * data_p ,
26- int * nobjs_p , int * * cumsizes_p , int * nsets_p )
25+ read_objective_t_data (const char * restrict filename ,
26+ objective_t * * restrict data_p ,
27+ int * restrict nobjs_p , int * * restrict cumsizes_p ,
28+ int * restrict nsets_p )
2729{
28- int nobjs = * nobjs_p ; /* number of objectives (and columns). */
29- int * cumsizes = * cumsizes_p ; /* cumulative sizes of data sets. */
30- int nsets = * nsets_p ; /* number of data sets. */
31- objective_t * data = * data_p ;
30+ objective_t * restrict data = * data_p ;
31+ int * restrict cumsizes = * cumsizes_p ; // Cumulative sizes of data sets.
32+ int nobjs = * nobjs_p ; // Number of objectives (and columns).
33+ int nsets = * nsets_p ; // Number of data sets.
3234
33- FILE * instream ;
35+ FILE * instream ;
3436
3537 if (filename == NULL ) {
3638 instream = stdin ;
@@ -52,8 +54,8 @@ read_objective_t_data (const char *filename, objective_t **data_p,
5254
5355 /* If size is equal to zero, this is equivalent to free().
5456 That is, reinitialize the data structures. */
55- data = realloc (data , datasize * sizeof (objective_t ));
56- cumsizes = realloc (cumsizes , sizessize * sizeof (int ));
57+ data = realloc (data , datasize * sizeof (* data ));
58+ cumsizes = realloc (cumsizes , sizessize * sizeof (* cumsizes ));
5759
5860 /* skip over leading whitespace, comments and empty lines. */
5961 int retval ; /* return value for fscanf */
@@ -73,18 +75,17 @@ read_objective_t_data (const char *filename, objective_t **data_p,
7375
7476 do {
7577 /* beginning of data set */
76- if ((size_t ) nsets == sizessize ) {
78+ if ((size_t ) nsets == sizessize ) {
7779 sizessize += CUMSIZE_INC ;
78- cumsizes = realloc (cumsizes , sizessize * sizeof (int ));
80+ cumsizes = realloc (cumsizes , sizessize * sizeof (* cumsizes ));
7981 }
8082
81- cumsizes [nsets ] = (nsets == 0 ) ? 0 : cumsizes [nsets - 1 ];
83+ cumsizes [nsets ] = (nsets == 0 ) ? 0 : cumsizes [nsets - 1 ];
8284
8385 do {
8486 /* beginning of row */
85- column = 0 ;
86-
87- do {
87+ column = 0 ;
88+ do {
8889 /* new column */
8990 column ++ ;
9091 objective_t number ;
@@ -116,10 +117,10 @@ read_objective_t_data (const char *filename, objective_t **data_p,
116117
117118 /* skip possible trailing whitespace */
118119 retval = skip_trailing_whitespace (instream );
119- } while (retval == 0 );
120+ } while (retval == 0 );
120121
121- if (!nobjs )
122- nobjs = column ;
122+ if (!nobjs )
123+ nobjs = column ;
123124 else if (likely (column == nobjs ))
124125 ; /* OK */
125126 else if (unlikely (cumsizes [0 ] == 0 )) { /* just finished first row. */
@@ -134,15 +135,15 @@ read_objective_t_data (const char *filename, objective_t **data_p,
134135 filename , line , column , nobjs );
135136 errorcode = ERROR_COLUMNS ;
136137 goto read_data_finish ;
137- }
138- cumsizes [nsets ]++ ;
138+ }
139+ cumsizes [nsets ]++ ;
139140
140141 /* look for an empty line */
141142 line ++ ;
142143 retval = skip_comment_line (instream );
143- } while (retval == 0 );
144+ } while (retval == 0 );
144145
145- nsets ++ ; /* new data set */
146+ nsets ++ ; /* new data set */
146147 DEBUG2_PRINT ("%s: set %d, read %d rows\n" ,
147148 filename , nsets , cumsizes [nsets - 1 ]);
148149 /* skip over successive empty lines */
@@ -154,8 +155,8 @@ read_objective_t_data (const char *filename, objective_t **data_p,
154155 } while (retval != EOF ); /* faster than !feof() */
155156
156157 /* adjust to real size (saves memory but probably slower). */
157- data = realloc (data , ntotal * sizeof (objective_t ));
158- cumsizes = realloc (cumsizes , nsets * sizeof (int ));
158+ data = realloc (data , ntotal * sizeof (* data ));
159+ cumsizes = realloc (cumsizes , nsets * sizeof (* cumsizes ));
159160
160161read_data_finish :
161162
0 commit comments