#include "d.h" static void read_chk(void* ptr, size_t size, size_t nmemb, FILE* fp, unsigned char **str) { if (fp) { if (fread(ptr, size, nmemb, fp) != nmemb) d_fail("error reading binary tables\n"); } else { memcpy(ptr, *str, size * nmemb); (*str) += size * nmemb; } } D_ParserTables * read_binary_tables_internal(FILE *fp, unsigned char *str, D_ReductionCode spec_code, D_ReductionCode final_code) { BinaryTablesHead tables; int i; char *tables_buf, *strings_buf; read_chk(&tables, sizeof(BinaryTablesHead), 1, fp, &str); tables_buf = MALLOC(tables.tables_size + tables.strings_size); read_chk(tables_buf, sizeof(char), tables.tables_size, fp, &str); strings_buf = tables_buf + tables.tables_size; read_chk(strings_buf, sizeof(char), tables.strings_size, fp, &str); for (i=0; i