From bfd0bee74eb4626eb6e4378019e53b0fd9aab013 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 30 Dec 2015 20:50:11 +0000 Subject: [PATCH] Use the OvflOffset() macro to try to remove some magic numbers from btree.c. FossilOrigin-Name: 1541607d458069f5db890b4ebe1c7e14ddf4e360 --- manifest | 18 ++++++++++-------- manifest.uuid | 2 +- src/btree.c | 8 ++++---- src/btreeInt.h | 7 +++++++ 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 4fb51ec6d3..7def7e7d0e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Reduce\sthe\ssize\sof\sthe\sCellInfo\sobject\sfrom\s32\sto\s24\sbytes\son\s64-bit\smachines,\nfor\sa\ssmall\sperformance\sincrease\sand\slibrary\ssize\sreduction. -D 2015-12-30T18:18:46.481 +C Use\sthe\sOvflOffset()\smacro\sto\stry\sto\sremove\ssome\smagic\snumbers\sfrom\sbtree.c. +D 2015-12-30T20:50:11.553 F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751 @@ -276,9 +276,9 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240 F src/backup.c 2869a76c03eb393ee795416e2387005553df72bc F src/bitvec.c 1a78d450a17c5016710eec900bedfc5729bf9bdf F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79 -F src/btree.c 5ac3f868d4f20a67f0f00a1014940f902b511558 +F src/btree.c ec6627fbb483526e0f6e095c0a438191fe6386b3 F src/btree.h 2d76dee44704c47eed323356a758662724b674a0 -F src/btreeInt.h b5f2651b41808f038dee9282c5dc0232ce6532d3 +F src/btreeInt.h dc698b04ae266bcce5f2eebba007133bf2339ef5 F src/build.c 5a8611a01cbf67c736d81304e054ec361ef8963d F src/callback.c 7b44ce59674338ad48b0e84e7b72f935ea4f68b0 F src/complete.c addcd8160b081131005d5bc2d34adf20c1c5c92f @@ -1406,8 +1406,10 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 3d81dfe3bc5ca9588b7796769d9be7a182f38b1c 7850715406458a61cff9eba5ad915f61f6d99482 -R 53c67154b7bbcd33ca0c18e39c81df1f -T +closed 7850715406458a61cff9eba5ad915f61f6d99482 +P 6a4cfc7ab62046eb718ce59eff6b632f239312ac +R c06b170488f3c7c74619bb001be96ae6 +T *branch * ovfloffset-macro +T *sym-ovfloffset-macro * +T -sym-trunk * U drh -Z f674907b91bbe0647e025dbc39f72b55 +Z bc33053752556a2a7906fec188dea6ee diff --git a/manifest.uuid b/manifest.uuid index 4b77ee57d3..54861125b7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6a4cfc7ab62046eb718ce59eff6b632f239312ac \ No newline at end of file +1541607d458069f5db890b4ebe1c7e14ddf4e360 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index df9455bc5b..51c346f938 100644 --- a/src/btree.c +++ b/src/btree.c @@ -1306,7 +1306,7 @@ static void ptrmapPutOvflPtr(MemPage *pPage, u8 *pCell, int *pRC){ assert( pCell!=0 ); pPage->xParseCell(pPage, pCell, &info); if( info.nLocalpBt, ovfl, PTRMAP_OVERFLOW1, pPage->pgno, pRC); } } @@ -3346,9 +3346,9 @@ static int modifyPagePointer(MemPage *pPage, Pgno iFrom, Pgno iTo, u8 eType){ pPage->xParseCell(pPage, pCell, &info); if( info.nLocalaData+pPage->maskPage - && iFrom==get4byte(pCell+info.nSize-4) + && iFrom==get4byte(pCell+OvflOffset(&info)) ){ - put4byte(pCell+info.nSize-4, iTo); + put4byte(pCell+OvflOffset(&info), iTo); break; } }else{ @@ -6855,7 +6855,7 @@ static int ptrmapCheckPages(MemPage **apPage, int nPage){ z = findCell(pPage, j); pPage->xParseCell(pPage, z, &info); if( info.nLocalpgno && e==PTRMAP_OVERFLOW1 ); } diff --git a/src/btreeInt.h b/src/btreeInt.h index a196e18a28..9d4549e3ac 100644 --- a/src/btreeInt.h +++ b/src/btreeInt.h @@ -473,6 +473,13 @@ struct CellInfo { u16 nSize; /* Size of the cell content on the main b-tree page */ }; +/* If X is a pointer to a CellInfo object for a cell, then OvflOffset(X) is +** the offset from the start of that cell to the first overflow page number +** for for that cell. +*/ +#define OvflOffset(X) ((X)->nSize-4) + + /* ** Maximum depth of an SQLite B-Tree structure. Any B-Tree deeper than ** this will be declared corrupt. This value is calculated based on a -- 2.39.5