Skip to content

Commit

Permalink
Merge pull request e8tools#224 from andreevlex/feature/issue-222
Browse files Browse the repository at this point in the history
Убран friend у MemBlock
  • Loading branch information
dmpas authored Mar 10, 2018
2 parents b3dc6e6 + 017ac15 commit b8dfd12
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/tool1cd/Class_1CD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ T_1CD::T_1CD(const string &_filename, MessageRegistrator *mess, bool _monopoly)
return;
}

MemBlock::pagesize = pagesize;
MemBlock::maxcount = ONE_GB / pagesize; // гигабайт
MemBlock::set_page_size(pagesize);
MemBlock::set_maxcount(ONE_GB / pagesize); // гигабайт
MemBlock::create_memblocks(length);

if(length != cont->length)
Expand Down
21 changes: 19 additions & 2 deletions src/tool1cd/MemBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
MemBlock* MemBlock::first = nullptr;
MemBlock* MemBlock::last = nullptr;
uint32_t MemBlock::count = 0;
uint32_t MemBlock::maxcount;
uint32_t MemBlock::maxcount = 0;
MemBlock** MemBlock::memblocks = nullptr;

uint64_t MemBlock::numblocks = 0;
Expand Down Expand Up @@ -43,7 +43,7 @@ MemBlock::MemBlock(TFileStream* fs, uint32_t _numblock, bool for_write, bool rea
fs->Seek((int64_t)numblock * pagesize, (TSeekOrigin)soFromBeginning);
fs->WriteBuffer(buf, pagesize);
fs->Seek(12, (TSeekOrigin)soFromBeginning);
fs->WriteBuffer(&numblock, 4);
fs->WriteBuffer(&numblock, sizeof(uint32_t));
}
else
{
Expand Down Expand Up @@ -194,6 +194,23 @@ void MemBlock::write()
is_changed = false;
}

uint32_t MemBlock::get_page_size()
{
return pagesize;
}

void MemBlock::set_page_size(const uint32_t value)
{
pagesize = value;
}

uint32_t MemBlock::get_maxcount()
{
return maxcount;
}

void MemBlock::set_maxcount(const uint32_t value)
{
maxcount = value;
}

8 changes: 7 additions & 1 deletion src/tool1cd/MemBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class T_1CD;
// последний в цепочке - с самым последним обращением
class MemBlock
{
friend T_1CD;
public:
static uint32_t count; // текущее количество кешированных блоков

Expand All @@ -30,6 +29,13 @@ friend T_1CD;
static void delete_memblocks();
static uint64_t get_numblocks();
static void flush();

static uint32_t get_page_size();
static void set_page_size(const uint32_t value);

static uint32_t get_maxcount();
static void set_maxcount(const uint32_t value);

private:
char* buf; // указатель на блок в памяти
static uint32_t pagesize; // размер одной страницы (до версии 8.2.14 всегда 0x1000 (4K), начиная с версии 8.3.8 от 0x1000 (4K) до 0x10000 (64K))
Expand Down

0 comments on commit b8dfd12

Please sign in to comment.