@@ -312,9 +312,9 @@ namespace
312312 const ULONG usedPages = sequence * pageMgr.pagesPerPIP + pipUsed;
313313
314314 const bool allocateExactNumberOfPages = dbb->dbb_flags & DBB_no_reserve;
315- const auto extensionResult = pageSpace->extend (tdbb, usedPages + initPages, allocateExactNumberOfPages);
316- if (extensionResult. success )
317- initPages = extensionResult. pagesAllocated ;
315+ const auto allocatedPages = pageSpace->extend (tdbb, usedPages + initPages, allocateExactNumberOfPages);
316+ if (allocatedPages. has_value () )
317+ initPages = allocatedPages. value () ;
318318 else
319319 {
320320 // For some reason fast file extension failed, maybe it is not supported by filesystem, or
@@ -1938,7 +1938,7 @@ ULONG PageSpace::usedPages(const Database* dbb)
19381938 return pgSpace->usedPages ();
19391939}
19401940
1941- PageSpace::ExtendResult PageSpace::extend (thread_db* tdbb, const ULONG pageNum, bool forceSize)
1941+ std::optional<ULONG> PageSpace::extend (thread_db* tdbb, const ULONG pageNum, bool forceSize)
19421942{
19431943/* *************************************
19441944 *
@@ -1958,11 +1958,11 @@ PageSpace::ExtendResult PageSpace::extend(thread_db* tdbb, const ULONG pageNum,
19581958 fb_assert (dbb == tdbb->getDatabase ());
19591959
19601960 if (!PIO_fast_extension_is_supported (*file))
1961- return {. success = false } ;
1961+ return std:: nullopt ;
19621962
19631963 // First, check it with the cached `maxPageNumber` value.
19641964 if (pageNum < maxPageNumber || pageNum < maxAlloc ())
1965- return {. success = true , . pagesAllocated = maxPageNumber - pageNum} ;
1965+ return maxPageNumber - pageNum;
19661966
19671967 const ULONG MAX_EXTEND_BYTES = static_cast <ULONG>(dbb->dbb_config ->getDatabaseGrowthIncrement ());
19681968 if (MAX_EXTEND_BYTES < MIN_EXTEND_BYTES)
@@ -1989,12 +1989,12 @@ PageSpace::ExtendResult PageSpace::extend(thread_db* tdbb, const ULONG pageNum,
19891989 try
19901990 {
19911991 if (!PIO_extend (tdbb, file, extPages, dbb->dbb_page_size ))
1992- return {. success = false } ;
1992+ return std:: nullopt ;
19931993
19941994 // File was extended, reset cached value
19951995 maxPageNumber = 0 ;
19961996
1997- return {. success = true , . pagesAllocated = extPages} ;
1997+ return extPages;
19981998 }
19991999 catch (const status_exception&)
20002000 {
@@ -2005,15 +2005,15 @@ PageSpace::ExtendResult PageSpace::extend(thread_db* tdbb, const ULONG pageNum,
20052005 // if file was extended, return, else try to extend by less pages
20062006
20072007 if (const auto newMaxPageNumber = maxAlloc (); oldMaxPageNumber < newMaxPageNumber)
2008- return {. success = true , . pagesAllocated = newMaxPageNumber - oldMaxPageNumber} ;
2008+ return newMaxPageNumber - oldMaxPageNumber;
20092009
20102010 extPages = MAX (reqPages, extPages / 2 );
20112011 }
20122012 else
20132013 {
20142014 gds__log (" Error extending file \" %s\" by %lu page(s).\n Currently allocated %lu pages, requested page number %lu" ,
20152015 file->fil_string , extPages, maxPageNumber, pageNum);
2016- return {. success = false } ;
2016+ return std:: nullopt ;
20172017 }
20182018 }
20192019 }
0 commit comments