mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 23:23:04 +01:00
Move class HugeStaticBuffer into common place, per Claudio request
This commit is contained in:
parent
de1695292e
commit
f700c79d81
@ -122,6 +122,25 @@ const UCHAR PIOB_success = 2; /* I/O successfully completed */
|
||||
const UCHAR PIOB_pending = 4; /* Asynchronous I/O not yet completed */
|
||||
#endif
|
||||
|
||||
static const int ZERO_BUF_SIZE = 1024 * 128;
|
||||
|
||||
class HugeStaticBuffer
|
||||
{
|
||||
public:
|
||||
HugeStaticBuffer(MemoryPool& p)
|
||||
: zeroArray(p),
|
||||
zeroBuff(zeroArray.getBuffer(ZERO_BUF_SIZE))
|
||||
{
|
||||
memset(zeroBuff, 0, ZERO_BUF_SIZE);
|
||||
}
|
||||
|
||||
const char* get() { return zeroBuff; }
|
||||
|
||||
private:
|
||||
Firebird::Array<char> zeroArray;
|
||||
char* zeroBuff;
|
||||
};
|
||||
|
||||
} //namespace Jrd
|
||||
|
||||
#endif // JRD_PIO_H
|
||||
|
@ -506,34 +506,9 @@ void PIO_header(Database* dbb, SCHAR * address, int length)
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace {
|
||||
// we need a class here only to return memory on shutdown and avoid
|
||||
// false memory leak reports
|
||||
static const int ZERO_BUF_SIZE = 1024 * 128;
|
||||
|
||||
class HugeStaticBuffer
|
||||
{
|
||||
public:
|
||||
explicit HugeStaticBuffer(MemoryPool& p)
|
||||
: zeroArray(p),
|
||||
zeroBuff(zeroArray.getBuffer(ZERO_BUF_SIZE))
|
||||
{
|
||||
memset(zeroBuff, 0, ZERO_BUF_SIZE);
|
||||
}
|
||||
|
||||
const char* get() const { return zeroBuff; }
|
||||
|
||||
private:
|
||||
// copying is prohibited
|
||||
HugeStaticBuffer(const HugeStaticBuffer&);
|
||||
HugeStaticBuffer& operator=(const HugeStaticBuffer&);
|
||||
|
||||
Firebird::Array<char> zeroArray;
|
||||
char* const zeroBuff;
|
||||
};
|
||||
|
||||
static Firebird::InitInstance<HugeStaticBuffer> zeros;
|
||||
}
|
||||
// we need a class here only to return memory on shutdown and avoid
|
||||
// false memory leak reports
|
||||
static Firebird::InitInstance<HugeStaticBuffer> zeros;
|
||||
|
||||
|
||||
USHORT PIO_init_data(Database* dbb, jrd_file* main_file, ISC_STATUS* status_vector,
|
||||
|
@ -481,34 +481,9 @@ void PIO_header(Database* dbb, SCHAR * address, int length)
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace {
|
||||
// we need a class here only to return memory on shutdown and avoid
|
||||
// false memory leak reports
|
||||
static const int ZERO_BUF_SIZE = 1024 * 128;
|
||||
|
||||
class HugeStaticBuffer
|
||||
{
|
||||
public:
|
||||
explicit HugeStaticBuffer(MemoryPool& p)
|
||||
: zeroArray(p),
|
||||
zeroBuff(zeroArray.getBuffer(ZERO_BUF_SIZE))
|
||||
{
|
||||
memset(zeroBuff, 0, ZERO_BUF_SIZE);
|
||||
}
|
||||
|
||||
const char* get() const { return zeroBuff; }
|
||||
|
||||
private:
|
||||
// copying is prohibited
|
||||
HugeStaticBuffer(const HugeStaticBuffer&);
|
||||
HugeStaticBuffer& operator=(const HugeStaticBuffer&);
|
||||
|
||||
Firebird::Array<char> zeroArray;
|
||||
char* const zeroBuff;
|
||||
};
|
||||
|
||||
static Firebird::InitInstance<HugeStaticBuffer> zeros;
|
||||
}
|
||||
// we need a class here only to return memory on shutdown and avoid
|
||||
// false memory leak reports
|
||||
static Firebird::InitInstance<HugeStaticBuffer> zeros;
|
||||
|
||||
|
||||
USHORT PIO_init_data(Database* dbb, jrd_file* main_file, ISC_STATUS* status_vector,
|
||||
|
Loading…
Reference in New Issue
Block a user