Skip to content

Commit

Permalink
Update table checker based on changes to table parser (resolves #77)
Browse files Browse the repository at this point in the history
  • Loading branch information
dharple committed Jul 24, 2021
1 parent cefb75b commit 4284a46
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/check_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "table.h"
#include "wrapped.h"

#define LINE_LENGTH 6

enum {
BASE_STATE,
INSIDE_STATE
Expand Down Expand Up @@ -53,18 +55,22 @@ static table_t *check_table(char *filename, int use_hash)
return NULL;
}

size = 0;

if (table_stat.st_size > 0) {
size = table_stat.st_size;
} else {
size = (512 * table_stat.st_blocks);
size = table_stat.st_size / LINE_LENGTH;
}

size /= 6;
#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
else {
size = (512 * table_stat.st_blocks) / LINE_LENGTH;
}
#endif

if (size < 500) {
size = 500;
}


table = table_init(size);
if (table == NULL) {
return NULL;
Expand Down

0 comments on commit 4284a46

Please sign in to comment.