@@ -101,12 +101,12 @@ using namespace Firebird;
101101
102102namespace
103103{
104- const char * const SCRATCH = " fb_table_" ;
105- const int MIN_EXTEND_BYTES = 128 * 1024 ; // 128KB
104+ constexpr const char * const SCRATCH = " fb_table_" ;
105+ constexpr int MIN_EXTEND_BYTES = 128 * 1024 ; // 128KB
106106
107107 inline void ensureDbWritable (thread_db* tdbb)
108108 {
109- const auto dbb = tdbb->getDatabase ();
109+ const auto * dbb = tdbb->getDatabase ();
110110
111111 if (dbb->readOnly ())
112112 ERR_post (Arg::Gds (isc_read_only_database));
@@ -115,11 +115,11 @@ namespace
115115 class HeaderClumplet
116116 {
117117 public:
118- HeaderClumplet (header_page* header, USHORT type)
118+ HeaderClumplet (header_page* header, USHORT type) noexcept
119119 : m_header(header), m_type(type)
120120 {}
121121
122- UCHAR* find (const UCHAR** clump_end = nullptr ) const
122+ UCHAR* find (const UCHAR** clump_end = nullptr ) const noexcept
123123 {
124124 UCHAR* p = m_header->hdr_data ;
125125 UCHAR* q = nullptr ;
@@ -136,7 +136,7 @@ namespace
136136 return q;
137137 }
138138
139- bool checkSpace (USHORT length) const
139+ bool checkSpace (USHORT length) const noexcept
140140 {
141141 const auto freeSpace = m_header->hdr_page_size - m_header->hdr_end ;
142142 if (freeSpace > 2 + length)
@@ -268,8 +268,8 @@ namespace
268268
269269 ULONG ensureDiskSpace (thread_db* tdbb, WIN* pip_window, const PageNumber pageNum, ULONG pipUsed)
270270 {
271- const auto dbb = tdbb->getDatabase ();
272- PageManager& pageMgr = dbb->dbb_page_manager ;
271+ const auto * dbb = tdbb->getDatabase ();
272+ const PageManager& pageMgr = dbb->dbb_page_manager ;
273273 PageSpace* const pageSpace = pageMgr.findPageSpace (pageNum.getPageSpaceID ());
274274
275275 ULONG newUsed = pipUsed;
@@ -449,9 +449,9 @@ PAG PAG_allocate_pages(thread_db* tdbb, WIN* window, unsigned cntAlloc, bool ali
449449 *
450450 **************************************/
451451 SET_TDBB (tdbb);
452- const auto dbb = tdbb->getDatabase ();
452+ const auto * dbb = tdbb->getDatabase ();
453453
454- PageManager& pageMgr = dbb->dbb_page_manager ;
454+ const PageManager& pageMgr = dbb->dbb_page_manager ;
455455 PageSpace* const pageSpace = pageMgr.findPageSpace (window->win_page .getPageSpaceID ());
456456 fb_assert (pageSpace);
457457
@@ -838,7 +838,7 @@ void PAG_format_pip(thread_db* tdbb, PageSpace& pageSpace)
838838 *
839839 **************************************/
840840 SET_TDBB (tdbb);
841- const auto dbb = tdbb->getDatabase ();
841+ const auto * dbb = tdbb->getDatabase ();
842842
843843 // Initialize first SCN's Page
844844 pageSpace.scnFirst = 0 ;
@@ -865,7 +865,7 @@ void PAG_format_pip(thread_db* tdbb, PageSpace& pageSpace)
865865 pages->pip_header .pag_type = pag_pages;
866866 pages->pip_used = (pageSpace.scnFirst ? pageSpace.scnFirst : pageSpace.pipFirst ) + 1 ;
867867 pages->pip_min = pages->pip_used ;
868- int count = dbb->dbb_page_size - static_cast <int >(offsetof (page_inv_page, pip_bits[0 ]));
868+ const int count = dbb->dbb_page_size - static_cast <int >(offsetof (page_inv_page, pip_bits[0 ]));
869869
870870 memset (pages->pip_bits , 0xFF , count);
871871
@@ -943,7 +943,7 @@ void PAG_header(thread_db* tdbb, bool info, const TriState newForceWrite)
943943 SET_TDBB (tdbb);
944944 Database* const dbb = tdbb->getDatabase ();
945945
946- const auto attachment = tdbb->getAttachment ();
946+ const auto * attachment = tdbb->getAttachment ();
947947 fb_assert (attachment);
948948
949949 WIN window (HEADER_PAGE_NUMBER);
@@ -1097,7 +1097,7 @@ void PAG_header_init(thread_db* tdbb)
10971097 SET_TDBB (tdbb);
10981098 const auto dbb = tdbb->getDatabase ();
10991099
1100- const auto attachment = tdbb->getAttachment ();
1100+ const auto * attachment = tdbb->getAttachment ();
11011101 fb_assert (attachment);
11021102
11031103 // Allocate a spare buffer which is large enough,
@@ -1118,7 +1118,7 @@ void PAG_header_init(thread_db* tdbb)
11181118 if (!PIO_header (tdbb, temp_page, headerSize))
11191119 ERR_post (Arg::Gds (isc_bad_db_format) << Arg::Str (attachment->att_filename ));
11201120
1121- const auto header = (header_page*) temp_page;
1121+ const auto * header = (header_page*) temp_page;
11221122
11231123 if (header->hdr_header .pag_type != pag_header || header->hdr_header .pag_pageno != HEADER_PAGE)
11241124 ERR_post (Arg::Gds (isc_bad_db_format) << Arg::Str (attachment->att_filename ));
@@ -1226,7 +1226,7 @@ void PAG_init2(thread_db* tdbb)
12261226 const auto dbb = tdbb->getDatabase ();
12271227
12281228 WIN window (HEADER_PAGE_NUMBER);
1229- const auto header = (header_page*) CCH_FETCH (tdbb, &window, LCK_read, pag_header);
1229+ const auto * header = (header_page*) CCH_FETCH (tdbb, &window, LCK_read, pag_header);
12301230
12311231 for (const UCHAR* p = header->hdr_data ; *p != HDR_end; p += 2 + p[1 ])
12321232 {
@@ -1265,7 +1265,7 @@ SLONG PAG_last_page(thread_db* tdbb)
12651265 *
12661266 **************************************/
12671267 SET_TDBB (tdbb);
1268- const auto dbb = tdbb->getDatabase ();
1268+ const auto * dbb = tdbb->getDatabase ();
12691269
12701270 return PageSpace::lastUsedPage (dbb);
12711271}
@@ -1306,9 +1306,9 @@ void PAG_release_pages(thread_db* tdbb, USHORT pageSpaceID, int cntRelease,
13061306 *
13071307 **************************************/
13081308 SET_TDBB (tdbb);
1309- const auto dbb = tdbb->getDatabase ();
1309+ const auto * dbb = tdbb->getDatabase ();
13101310
1311- PageManager& pageMgr = dbb->dbb_page_manager ;
1311+ const PageManager& pageMgr = dbb->dbb_page_manager ;
13121312 PageSpace* const pageSpace = pageMgr.findPageSpace (pageSpaceID);
13131313 fb_assert (pageSpace);
13141314
@@ -1521,7 +1521,7 @@ void PAG_set_db_readonly(thread_db* tdbb, bool flag)
15211521 // Take into account current attachment ID, else next attachment
15221522 // (cache writer, for examle) will get the same att ID and wait
15231523 // for att lock indefinitely.
1524- Attachment* att = tdbb->getAttachment ();
1524+ const Attachment* att = tdbb->getAttachment ();
15251525 if (att->att_attachment_id )
15261526 header->hdr_attachment_id = att->att_attachment_id ;
15271527
@@ -1756,7 +1756,7 @@ ULONG PageSpace::maxAlloc(const Database* dbb)
17561756 return pgSpace->maxAlloc ();
17571757}
17581758
1759- bool PageSpace::onRawDevice () const
1759+ bool PageSpace::onRawDevice () const noexcept
17601760{
17611761 return (file->fil_flags & FIL_raw_device) != 0 ;
17621762}
@@ -1782,18 +1782,18 @@ ULONG PageSpace::lastUsedPage()
17821782
17831783 while (true )
17841784 {
1785- pag* page = CCH_FETCH (tdbb, &window, LCK_read, pag_undefined);
1785+ const pag* page = CCH_FETCH (tdbb, &window, LCK_read, pag_undefined);
17861786
17871787 if (moveUp)
17881788 {
17891789 fb_assert (page->pag_type == pag_pages);
17901790
1791- page_inv_page* pip = (page_inv_page*) page;
1791+ const page_inv_page* pip = (page_inv_page*) page;
17921792
17931793 if (pip->pip_used != pageMgr.pagesPerPIP )
17941794 break ;
17951795
1796- UCHAR lastByte = pip->pip_bits [pageMgr.bytesBitPIP - 1 ];
1796+ const UCHAR lastByte = pip->pip_bits [pageMgr.bytesBitPIP - 1 ];
17971797 if (lastByte & 0x80 )
17981798 break ;
17991799 }
@@ -1822,7 +1822,7 @@ ULONG PageSpace::lastUsedPage()
18221822 window.win_page = pipLast;
18231823 }
18241824
1825- page_inv_page* pip = (page_inv_page*) window.win_buffer ;
1825+ const page_inv_page* pip = (page_inv_page*) window.win_buffer ;
18261826
18271827 int last_bit = pip->pip_used ;
18281828 int byte_num = last_bit / 8 ;
@@ -1903,7 +1903,7 @@ ULONG PageSpace::usedPages()
19031903
19041904 while (true )
19051905 {
1906- page_inv_page* pip = (page_inv_page*) CCH_FETCH (tdbb, &window, LCK_read, pag_undefined);
1906+ const page_inv_page* pip = (page_inv_page*) CCH_FETCH (tdbb, &window, LCK_read, pag_undefined);
19071907 if (pip->pip_header .pag_type != pag_pages)
19081908 {
19091909 CCH_RELEASE (tdbb, &window);
@@ -2006,7 +2006,7 @@ bool PageSpace::extend(thread_db* tdbb, const ULONG pageNum, const bool forceSiz
20062006 return true ;
20072007}
20082008
2009- ULONG PageSpace::getSCNPageNum (ULONG sequence)
2009+ ULONG PageSpace::getSCNPageNum (ULONG sequence) noexcept
20102010{
20112011/* *************************************
20122012 *
@@ -2076,7 +2076,7 @@ void PageManager::closeAll()
20762076void PageManager::initTempPageSpace (thread_db* tdbb)
20772077{
20782078 SET_TDBB (tdbb);
2079- Database* const dbb = tdbb->getDatabase ();
2079+ const Database* dbb = tdbb->getDatabase ();
20802080
20812081 fb_assert (tempPageSpaceID == 0 );
20822082
@@ -2199,10 +2199,10 @@ ULONG PAG_page_count(thread_db* tdbb)
21992199
22002200void PAG_set_page_scn (thread_db* tdbb, win* window)
22012201{
2202- Database* dbb = tdbb->getDatabase ();
2202+ const Database* dbb = tdbb->getDatabase ();
22032203 fb_assert (dbb->dbb_ods_version >= ODS_VERSION12);
22042204
2205- PageManager& pageMgr = dbb->dbb_page_manager ;
2205+ const PageManager& pageMgr = dbb->dbb_page_manager ;
22062206 PageSpace* const pageSpace = pageMgr.findPageSpace (window->win_page .getPageSpaceID ());
22072207
22082208 if (pageSpace->isTemporary ())
0 commit comments