mirror of
https://github.com/Dushistov/sdcv.git
synced 2025-12-15 17:31:56 +00:00
Synonyms: Use MapFile
This commit is contained in:
@@ -831,25 +831,16 @@ bool WordListIndex::lookup(const char *str, glong &idx)
|
|||||||
|
|
||||||
bool SynFile::load(const std::string &url, gulong wc)
|
bool SynFile::load(const std::string &url, gulong wc)
|
||||||
{
|
{
|
||||||
|
|
||||||
struct stat stat_buf;
|
struct stat stat_buf;
|
||||||
if (!stat(url.c_str(), &stat_buf)) {
|
if (!stat(url.c_str(), &stat_buf)) {
|
||||||
|
|
||||||
FILE *in = fopen(url.c_str(), "rb");
|
MapFile syn;
|
||||||
if (!in)
|
if (!syn.open(url.c_str(), stat_buf.st_size))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
fseek(in, 0, SEEK_END);
|
syndatabuf = (gchar *)g_malloc(stat_buf.st_size);
|
||||||
gulong fsize = ftell(in);
|
memcpy(syndatabuf, syn.begin(), stat_buf.st_size);
|
||||||
fseek(in, 0, SEEK_SET);
|
|
||||||
syndatabuf = (gchar *)g_malloc(fsize);
|
|
||||||
|
|
||||||
const int len = fread(syndatabuf, 1, fsize, in);
|
|
||||||
fclose(in);
|
|
||||||
if (len < 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (gulong(len) != fsize)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
synlist.resize(wc + 1);
|
synlist.resize(wc + 1);
|
||||||
gchar *p1 = syndatabuf;
|
gchar *p1 = syndatabuf;
|
||||||
|
|||||||
Reference in New Issue
Block a user