#include "solution.h"
-void solution_set(struct symlist *sl, FILE * f) {
+void solution_check(struct symlist *sl, FILE * f) {
int c;
// skip first line
do
ww = w + 1;
}
int id = atoi(ww);
+ if ((unsigned) id > sl->maxid)
+ break;
if (id == 0)
continue;
if (sl->array[id - 1].sym == NULL)
#ifndef _SOLUTION_H_
#define _SOLUTION_H_
-void solution_set(struct symlist *sl, FILE * f);
+void solution_check(struct symlist *sl, FILE * f);
#endif /* _SOLUTION_H_ */
struct symlist *ret;
ret = malloc(sizeof(struct symlist));
ret->size = 1;
+ ret->maxid = 0;
ret->array = malloc(ret->size * sizeof(struct symlist_el));
unsigned int id;
realloc(ret->array,
ret->size * sizeof(struct symlist_el));
}
+ if (id > ret->maxid)
+ ret->maxid = id;
ret->array[(size_t) id - 1].id = id;
if (!strncmp(w, NONAMEGEN, strlen(NONAMEGEN)))
ret->array[(size_t) id - 1].sym = NULL;
struct symlist {
struct symlist_el *array;
size_t size;
+ unsigned maxid;
};
struct symlist *symlist_read(FILE *f);
Eprintf("Can't open file: %s\n", solution_file);
exit(2);
}
- solution_set(sl, f);
+ solution_check(sl, f);
fclose(f);
conf_write(".config");