8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-24 07:23:03 +01:00

Better type clearness.

This commit is contained in:
dimitr 2011-04-18 07:55:33 +00:00
parent f253836d3a
commit c3aefbaa09
3 changed files with 21 additions and 26 deletions

View File

@ -65,7 +65,7 @@ TempSpace::Block::Block(Block* tail, size_t length)
TempSpace::MemoryBlock::MemoryBlock(MemoryPool& pool, Block* tail, size_t length)
: Block(tail, length)
{
ptr = FB_NEW(pool) char[length];
ptr = FB_NEW(pool) UCHAR[length];
}
TempSpace::MemoryBlock::~MemoryBlock()
@ -212,7 +212,7 @@ size_t TempSpace::read(offset_t offset, void* buffer, size_t length)
// search for the first needed block
Block* block = findBlock(offset);
char* p = static_cast<char*>(buffer);
UCHAR* p = static_cast<UCHAR*>(buffer);
size_t l = length;
// read data from the block chain
@ -250,7 +250,7 @@ size_t TempSpace::write(offset_t offset, const void* buffer, size_t length)
// search for the first needed block
Block* const block = findBlock(offset);
const char* p = static_cast<const char*>(buffer);
const UCHAR* p = static_cast<const UCHAR*>(buffer);
size_t l = length;
// write data to as many blocks as necessary
@ -522,7 +522,7 @@ void TempSpace::releaseSpace(offset_t position, size_t size)
// Return contiguous chunk of memory if present at given location
//
char* TempSpace::inMemory(offset_t begin, size_t size) const
UCHAR* TempSpace::inMemory(offset_t begin, size_t size) const
{
const Block* block = findBlock(begin);
return block ? block->inMemory(begin, size) : NULL;
@ -535,7 +535,7 @@ char* TempSpace::inMemory(offset_t begin, size_t size) const
// of search range if found
//
char* TempSpace::findMemory(offset_t& begin, offset_t end, size_t size) const
UCHAR* TempSpace::findMemory(offset_t& begin, offset_t end, size_t size) const
{
offset_t local_offset = begin;
const offset_t save_begin = begin;
@ -543,7 +543,7 @@ char* TempSpace::findMemory(offset_t& begin, offset_t end, size_t size) const
while (block && (begin + size <= end))
{
char* mem = block->inMemory(local_offset, size);
UCHAR* const mem = block->inMemory(local_offset, size);
if (mem)
{
return mem;
@ -611,21 +611,21 @@ size_t TempSpace::allocateBatch(size_t count, size_t minSize, size_t maxSize, Se
offset_t freeEnd = freeSpace ? freeSpace->position + freeSpace->size : 0;
while (segments.getCount() < count && freeSpace)
{
char* mem = findMemory(freeSeek, freeEnd, freeMem);
UCHAR* const mem = findMemory(freeSeek, freeEnd, freeMem);
if (mem)
{
fb_assert(freeSeek + freeMem <= freeEnd);
#ifdef DEV_BUILD
offset_t seek1 = freeSeek;
char* p = findMemory(seek1, freeEnd, freeMem);
UCHAR* const p = findMemory(seek1, freeEnd, freeMem);
fb_assert(p == mem);
fb_assert(seek1 == freeSeek);
#endif
if (freeSeek != freeSpace->position)
{
const ULONG skip_size = freeSeek - freeSpace->position;
Segment* skip_space = getSegment(freeSpace->position, skip_size);
Segment* const skip_space = getSegment(freeSpace->position, skip_size);
(*prevSpace) = skip_space;
skip_space->next = freeSpace;

View File

@ -51,11 +51,11 @@ public:
offset_t allocateSpace(size_t size);
void releaseSpace(offset_t offset, size_t size);
char* inMemory(offset_t offset, size_t size) const;
UCHAR* inMemory(offset_t offset, size_t size) const;
struct SegmentInMemory
{
char* memory;
UCHAR* memory;
offset_t position;
size_t size;
};
@ -77,7 +77,7 @@ private:
virtual size_t read(offset_t offset, void* buffer, size_t length) = 0;
virtual size_t write(offset_t offset, const void* buffer, size_t length) = 0;
virtual char* inMemory(offset_t offset, size_t size) const = 0;
virtual UCHAR* inMemory(offset_t offset, size_t size) const = 0;
virtual bool sameFile(const Firebird::TempFile* file) const = 0;
Block *prev;
@ -94,7 +94,7 @@ private:
size_t read(offset_t offset, void* buffer, size_t length);
size_t write(offset_t offset, const void* buffer, size_t length);
char* inMemory(offset_t offset, size_t _size) const
UCHAR* inMemory(offset_t offset, size_t _size) const
{
if ((offset < this->size) && (offset + _size <= this->size))
return ptr + offset;
@ -108,7 +108,7 @@ private:
}
private:
char* ptr;
UCHAR* ptr;
};
class FileBlock : public Block
@ -120,7 +120,7 @@ private:
size_t read(offset_t offset, void* buffer, size_t length);
size_t write(offset_t offset, const void* buffer, size_t length);
char* inMemory(offset_t /*offset*/, size_t /*a_size*/) const
UCHAR* inMemory(offset_t /*offset*/, size_t /*a_size*/) const
{
return NULL;
}
@ -138,12 +138,7 @@ private:
Block* findBlock(offset_t& offset) const;
Firebird::TempFile* setupFile(size_t size);
virtual bool adjustCacheSize(long) const
{
return false;
}
char* findMemory(offset_t& begin, offset_t end, size_t size) const;
UCHAR* findMemory(offset_t& begin, offset_t end, size_t size) const;
// free/used segments management
class Segment

View File

@ -1924,10 +1924,10 @@ static ULONG allocate_memory(sort_context* scb, ULONG n, ULONG chunkSize, bool u
// if some run's already in memory cache - use this memory
for (run = scb->scb_runs, count = 0; count < n; run = run->run_next, count++)
{
run->run_buffer = 0;
run->run_buffer = NULL;
char* mem = 0;
if (mem = scb->scb_space->inMemory(run->run_seek, run->run_size))
UCHAR* mem = scb->scb_space->inMemory(run->run_seek, run->run_size);
if (mem)
{
run->run_buffer = reinterpret_cast<SORTP*>(mem);
run->run_record = reinterpret_cast<sort_record*>(mem);
@ -1956,7 +1956,7 @@ static ULONG allocate_memory(sort_context* scb, ULONG n, ULONG chunkSize, bool u
if (!run->run_buffer)
{
const size_t runSize = MIN(seg->size / rec_size, run->run_records) * rec_size;
char* mem = seg->memory;
UCHAR* mem = seg->memory;
run->run_mem_seek = seg->position;
run->run_mem_size = seg->size;
@ -2479,7 +2479,7 @@ static void order_and_save(sort_context* scb)
run->run_size = run->run_records * key_length;
run->run_seek = scb->scb_space->allocateSpace(run->run_size);
char* mem = scb->scb_space->inMemory(run->run_seek, run->run_size);
UCHAR* mem = scb->scb_space->inMemory(run->run_seek, run->run_size);
if (mem)
{