Skip to content

Commit 90c6f91

Browse files
authored
Merge pull request #130 from mdorier/fix-various-issues
Fix undefined NULL and pgno error from C++ compilers
2 parents 825d16c + b478afd commit 90c6f91

File tree

5 files changed

+49
-43
lines changed

5 files changed

+49
-43
lines changed

src/lhash_kv.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ static int lhash_read_header(lhash_kv_engine *pEngine,unqlite_page *pHeader)
912912
/* Initialiaze the bucket map */
913913
pMap = &pEngine->sPageMap;
914914
/* Fill in the structure */
915-
pMap->iNum = pHeader->pgno;
915+
pMap->iNum = pHeader->iPage;
916916
/* Next page in the bucket map */
917917
SyBigEndianUnpack64(zRaw,&pMap->iNext);
918918
zRaw += 8;
@@ -1061,20 +1061,20 @@ static int lhMapWriteRecord(lhash_kv_engine *pEngine,pgno iLogic,pgno iReal)
10611061
}
10621062
/* Reflect the change */
10631063
pMap->iNext = 0;
1064-
pMap->iNum = pPage->pgno;
1064+
pMap->iNum = pPage->iPage;
10651065
pMap->nRec = 0;
10661066
pMap->iPtr = 8/* Next page number */+4/* Total records in the map*/;
10671067
/* Link this page */
10681068
rc = pEngine->pIo->xWrite(pOld);
10691069
if( rc != UNQLITE_OK ){
10701070
return rc;
10711071
}
1072-
if( pOld->pgno == pEngine->pHeader->pgno ){
1072+
if( pOld->iPage == pEngine->pHeader->iPage ){
10731073
/* First page (Hash header) */
1074-
SyBigEndianPack64(&pOld->zData[4/*magic*/+4/*hash*/+8/* Free page */+8/*current split bucket*/+8/*Maximum split bucket*/],pPage->pgno);
1074+
SyBigEndianPack64(&pOld->zData[4/*magic*/+4/*hash*/+8/* Free page */+8/*current split bucket*/+8/*Maximum split bucket*/],pPage->iPage);
10751075
}else{
10761076
/* Link the new page */
1077-
SyBigEndianPack64(pOld->zData,pPage->pgno);
1077+
SyBigEndianPack64(pOld->zData,pPage->iPage);
10781078
/* Unref */
10791079
pEngine->pIo->xPageUnref(pOld);
10801080
}
@@ -1107,7 +1107,7 @@ static int lhMapWriteRecord(lhash_kv_engine *pEngine,pgno iLogic,pgno iReal)
11071107
if( rc == UNQLITE_OK ){
11081108
/* Total number of records */
11091109
pMap->nRec++;
1110-
if( pPage->pgno == pEngine->pHeader->pgno ){
1110+
if( pPage->iPage == pEngine->pHeader->iPage ){
11111111
/* Page one: Always writable */
11121112
SyBigEndianPack32(
11131113
&pPage->zData[4/*magic*/+4/*hash*/+8/* Free page */+8/*current split bucket*/+8/*Maximum split bucket*/+8/*Next map page*/],
@@ -1145,7 +1145,7 @@ static int lhPageDefragment(lhpage *pPage)
11451145
/* No more cells */
11461146
break;
11471147
}
1148-
if( pCell->pPage->pRaw->pgno == pPage->pRaw->pgno ){
1148+
if( pCell->pPage->pRaw->iPage == pPage->pRaw->iPage ){
11491149
/* Cell payload if locally stored */
11501150
zPayload = 0;
11511151
if( pCell->iOvfl == 0 ){
@@ -1374,7 +1374,7 @@ static int lhCellWriteOvflPayload(lhcell *pCell,const void *pKey,sxu32 nKeylen,.
13741374
}
13751375
pFirst = pOvfl;
13761376
/* Link */
1377-
pCell->iOvfl = pOvfl->pgno;
1377+
pCell->iOvfl = pOvfl->iPage;
13781378
/* Update the cell header */
13791379
SyBigEndianPack64(&pPage->pRaw->zData[pCell->iStart + 4/*Hash*/ + 4/*Key*/ + 8/*Data*/ + 2 /*Next cell*/],pCell->iOvfl);
13801380
/* Start the write process */
@@ -1400,7 +1400,7 @@ static int lhCellWriteOvflPayload(lhcell *pCell,const void *pKey,sxu32 nKeylen,.
14001400
return rc;
14011401
}
14021402
/* Link */
1403-
SyBigEndianPack64(pOvfl->zData,pNew->pgno);
1403+
SyBigEndianPack64(pOvfl->zData,pNew->iPage);
14041404
pEngine->pIo->xPageUnref(pOvfl);
14051405
SyBigEndianPack64(pNew->zData,0); /* Next overflow page on the chain */
14061406
pOvfl = pNew;
@@ -1419,7 +1419,7 @@ static int lhCellWriteOvflPayload(lhcell *pCell,const void *pKey,sxu32 nKeylen,.
14191419
}
14201420
rc = UNQLITE_OK;
14211421
va_start(ap,nKeylen);
1422-
pCell->iDataPage = pNew->pgno;
1422+
pCell->iDataPage = pNew->iPage;
14231423
pCell->iDataOfft = (sxu16)(zRaw-pNew->zData);
14241424
/* Write the data page and its offset */
14251425
SyBigEndianPack64(&pFirst->zData[8/*Next ovfl*/],pCell->iDataPage);
@@ -1455,7 +1455,7 @@ static int lhCellWriteOvflPayload(lhcell *pCell,const void *pKey,sxu32 nKeylen,.
14551455
return rc;
14561456
}
14571457
/* Link */
1458-
SyBigEndianPack64(pOvfl->zData,pNew->pgno);
1458+
SyBigEndianPack64(pOvfl->zData,pNew->iPage);
14591459
pEngine->pIo->xPageUnref(pOvfl);
14601460
SyBigEndianPack64(pNew->zData,0); /* Next overflow page on the chain */
14611461
pOvfl = pNew;
@@ -1494,7 +1494,7 @@ static int lhRestorePage(lhash_kv_engine *pEngine,unqlite_page *pPage)
14941494
}
14951495
/* Link to the list of free page */
14961496
SyBigEndianPack64(pPage->zData,pEngine->nFreeList);
1497-
pEngine->nFreeList = pPage->pgno;
1497+
pEngine->nFreeList = pPage->iPage;
14981498
SyBigEndianPack64(&pEngine->pHeader->zData[4/*Magic*/+4/*Hash*/],pEngine->nFreeList);
14991499
/* All done */
15001500
return UNQLITE_OK;
@@ -1764,7 +1764,7 @@ static int lhRecordOverwrite(
17641764
return rc;
17651765
}
17661766
/* Link */
1767-
SyBigEndianPack64(pOvfl->zData,pNew->pgno);
1767+
SyBigEndianPack64(pOvfl->zData,pNew->iPage);
17681768
pEngine->pIo->xPageUnref(pOvfl);
17691769
SyBigEndianPack64(pNew->zData,0); /* Next overflow page on the chain */
17701770
pOvfl = pNew;
@@ -1925,7 +1925,7 @@ static int lhRecordAppend(
19251925
return rc;
19261926
}
19271927
/* Link */
1928-
SyBigEndianPack64(pOvfl->zData,pNew->pgno);
1928+
SyBigEndianPack64(pOvfl->zData,pNew->iPage);
19291929
pEngine->pIo->xPageUnref(pOvfl);
19301930
SyBigEndianPack64(pNew->zData,0); /* Next overflow page on the chain */
19311931
pOvfl = pNew;
@@ -2136,8 +2136,8 @@ static int lhFindSlavePage(lhpage *pPage,sxu64 nAmount,sxu16 *pOfft,lhpage **ppS
21362136
goto fail;
21372137
}
21382138
/* Reflect in the page header */
2139-
SyBigEndianPack64(&pSlave->pRaw->zData[2/*Cell offset*/+2/*Free block offset*/],pRaw->pgno);
2140-
pSlave->sHdr.iSlave = pRaw->pgno;
2139+
SyBigEndianPack64(&pSlave->pRaw->zData[2/*Cell offset*/+2/*Free block offset*/],pRaw->iPage);
2140+
pSlave->sHdr.iSlave = pRaw->iPage;
21412141
/* All done */
21422142
*ppSlave = pNew;
21432143
return UNQLITE_OK;
@@ -2316,12 +2316,12 @@ static int lhSplit(lhpage *pTarget,int *pRetry)
23162316
/* Install and write the logical map record */
23172317
rc = lhMapWriteRecord(pEngine,
23182318
pEngine->split_bucket + pEngine->max_split_bucket,
2319-
pRaw->pgno
2319+
pRaw->iPage
23202320
);
23212321
if( rc != UNQLITE_OK ){
23222322
goto fail;
23232323
}
2324-
if( pTarget->pRaw->pgno == pOld->pRaw->pgno ){
2324+
if( pTarget->pRaw->iPage == pOld->pRaw->iPage ){
23252325
*pRetry = 1;
23262326
}
23272327
/* Perform the split */
@@ -2444,7 +2444,7 @@ static int lh_record_insert(
24442444
rc = lhStoreCell(pPage,pKey,nKeyLen,pData,nDataLen,nHash,1);
24452445
if( rc == UNQLITE_OK ){
24462446
/* Install and write the logical map record */
2447-
rc = lhMapWriteRecord(pEngine,iBucket,pRaw->pgno);
2447+
rc = lhMapWriteRecord(pEngine,iBucket,pRaw->iPage);
24482448
}
24492449
pEngine->pIo->xPageUnref(pRaw);
24502450
return rc;
@@ -2532,7 +2532,7 @@ static int lhash_write_header(lhash_kv_engine *pEngine,unqlite_page *pHeader)
25322532
/* Initialiaze the bucket map */
25332533
pMap = &pEngine->sPageMap;
25342534
/* Fill in the structure */
2535-
pMap->iNum = pHeader->pgno;
2535+
pMap->iNum = pHeader->iPage;
25362536
/* Next page in the bucket map */
25372537
SyBigEndianPack64(zRaw,0);
25382538
zRaw += 8;

src/pager.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@
129129
**
130130
**
131131
*/
132+
#ifndef NULL
133+
#define NULL 0
134+
#endif
132135
#define PAGER_OPEN 0
133136
#define PAGER_READER 1
134137
#define PAGER_WRITER_LOCKED 2

src/unqlite.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ struct unqlite_page
661661
{
662662
unsigned char *zData; /* Content of this page */
663663
void *pUserData; /* Extra content */
664-
pgno pgno; /* Page number for this page */
664+
pgno iPage; /* Page number for this page */
665665
};
666666
/*
667667
* UnQLite handle to the underlying Key/Value Storage Engine (See below).

unqlite.c

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ struct unqlite_page
730730
{
731731
unsigned char *zData; /* Content of this page */
732732
void *pUserData; /* Extra content */
733-
pgno pgno; /* Page number for this page */
733+
pgno iPage; /* Page number for this page */
734734
};
735735
/*
736736
* UnQLite handle to the underlying Key/Value Storage Engine (See below).
@@ -49599,7 +49599,7 @@ static int lhash_read_header(lhash_kv_engine *pEngine,unqlite_page *pHeader)
4959949599
/* Initialiaze the bucket map */
4960049600
pMap = &pEngine->sPageMap;
4960149601
/* Fill in the structure */
49602-
pMap->iNum = pHeader->pgno;
49602+
pMap->iNum = pHeader->iPage;
4960349603
/* Next page in the bucket map */
4960449604
SyBigEndianUnpack64(zRaw,&pMap->iNext);
4960549605
zRaw += 8;
@@ -49748,20 +49748,20 @@ static int lhMapWriteRecord(lhash_kv_engine *pEngine,pgno iLogic,pgno iReal)
4974849748
}
4974949749
/* Reflect the change */
4975049750
pMap->iNext = 0;
49751-
pMap->iNum = pPage->pgno;
49751+
pMap->iNum = pPage->iPage;
4975249752
pMap->nRec = 0;
4975349753
pMap->iPtr = 8/* Next page number */+4/* Total records in the map*/;
4975449754
/* Link this page */
4975549755
rc = pEngine->pIo->xWrite(pOld);
4975649756
if( rc != UNQLITE_OK ){
4975749757
return rc;
4975849758
}
49759-
if( pOld->pgno == pEngine->pHeader->pgno ){
49759+
if( pOld->iPage == pEngine->pHeader->iPage ){
4976049760
/* First page (Hash header) */
49761-
SyBigEndianPack64(&pOld->zData[4/*magic*/+4/*hash*/+8/* Free page */+8/*current split bucket*/+8/*Maximum split bucket*/],pPage->pgno);
49761+
SyBigEndianPack64(&pOld->zData[4/*magic*/+4/*hash*/+8/* Free page */+8/*current split bucket*/+8/*Maximum split bucket*/],pPage->iPage);
4976249762
}else{
4976349763
/* Link the new page */
49764-
SyBigEndianPack64(pOld->zData,pPage->pgno);
49764+
SyBigEndianPack64(pOld->zData,pPage->iPage);
4976549765
/* Unref */
4976649766
pEngine->pIo->xPageUnref(pOld);
4976749767
}
@@ -49794,7 +49794,7 @@ static int lhMapWriteRecord(lhash_kv_engine *pEngine,pgno iLogic,pgno iReal)
4979449794
if( rc == UNQLITE_OK ){
4979549795
/* Total number of records */
4979649796
pMap->nRec++;
49797-
if( pPage->pgno == pEngine->pHeader->pgno ){
49797+
if( pPage->iPage == pEngine->pHeader->iPage ){
4979849798
/* Page one: Always writable */
4979949799
SyBigEndianPack32(
4980049800
&pPage->zData[4/*magic*/+4/*hash*/+8/* Free page */+8/*current split bucket*/+8/*Maximum split bucket*/+8/*Next map page*/],
@@ -49832,7 +49832,7 @@ static int lhPageDefragment(lhpage *pPage)
4983249832
/* No more cells */
4983349833
break;
4983449834
}
49835-
if( pCell->pPage->pRaw->pgno == pPage->pRaw->pgno ){
49835+
if( pCell->pPage->pRaw->iPage == pPage->pRaw->iPage ){
4983649836
/* Cell payload if locally stored */
4983749837
zPayload = 0;
4983849838
if( pCell->iOvfl == 0 ){
@@ -50061,7 +50061,7 @@ static int lhCellWriteOvflPayload(lhcell *pCell,const void *pKey,sxu32 nKeylen,.
5006150061
}
5006250062
pFirst = pOvfl;
5006350063
/* Link */
50064-
pCell->iOvfl = pOvfl->pgno;
50064+
pCell->iOvfl = pOvfl->iPage;
5006550065
/* Update the cell header */
5006650066
SyBigEndianPack64(&pPage->pRaw->zData[pCell->iStart + 4/*Hash*/ + 4/*Key*/ + 8/*Data*/ + 2 /*Next cell*/],pCell->iOvfl);
5006750067
/* Start the write process */
@@ -50087,7 +50087,7 @@ static int lhCellWriteOvflPayload(lhcell *pCell,const void *pKey,sxu32 nKeylen,.
5008750087
return rc;
5008850088
}
5008950089
/* Link */
50090-
SyBigEndianPack64(pOvfl->zData,pNew->pgno);
50090+
SyBigEndianPack64(pOvfl->zData,pNew->iPage);
5009150091
pEngine->pIo->xPageUnref(pOvfl);
5009250092
SyBigEndianPack64(pNew->zData,0); /* Next overflow page on the chain */
5009350093
pOvfl = pNew;
@@ -50106,7 +50106,7 @@ static int lhCellWriteOvflPayload(lhcell *pCell,const void *pKey,sxu32 nKeylen,.
5010650106
}
5010750107
rc = UNQLITE_OK;
5010850108
va_start(ap,nKeylen);
50109-
pCell->iDataPage = pNew->pgno;
50109+
pCell->iDataPage = pNew->iPage;
5011050110
pCell->iDataOfft = (sxu16)(zRaw-pNew->zData);
5011150111
/* Write the data page and its offset */
5011250112
SyBigEndianPack64(&pFirst->zData[8/*Next ovfl*/],pCell->iDataPage);
@@ -50142,7 +50142,7 @@ static int lhCellWriteOvflPayload(lhcell *pCell,const void *pKey,sxu32 nKeylen,.
5014250142
return rc;
5014350143
}
5014450144
/* Link */
50145-
SyBigEndianPack64(pOvfl->zData,pNew->pgno);
50145+
SyBigEndianPack64(pOvfl->zData,pNew->iPage);
5014650146
pEngine->pIo->xPageUnref(pOvfl);
5014750147
SyBigEndianPack64(pNew->zData,0); /* Next overflow page on the chain */
5014850148
pOvfl = pNew;
@@ -50181,7 +50181,7 @@ static int lhRestorePage(lhash_kv_engine *pEngine,unqlite_page *pPage)
5018150181
}
5018250182
/* Link to the list of free page */
5018350183
SyBigEndianPack64(pPage->zData,pEngine->nFreeList);
50184-
pEngine->nFreeList = pPage->pgno;
50184+
pEngine->nFreeList = pPage->iPage;
5018550185
SyBigEndianPack64(&pEngine->pHeader->zData[4/*Magic*/+4/*Hash*/],pEngine->nFreeList);
5018650186
/* All done */
5018750187
return UNQLITE_OK;
@@ -50451,7 +50451,7 @@ static int lhRecordOverwrite(
5045150451
return rc;
5045250452
}
5045350453
/* Link */
50454-
SyBigEndianPack64(pOvfl->zData,pNew->pgno);
50454+
SyBigEndianPack64(pOvfl->zData,pNew->iPage);
5045550455
pEngine->pIo->xPageUnref(pOvfl);
5045650456
SyBigEndianPack64(pNew->zData,0); /* Next overflow page on the chain */
5045750457
pOvfl = pNew;
@@ -50612,7 +50612,7 @@ static int lhRecordAppend(
5061250612
return rc;
5061350613
}
5061450614
/* Link */
50615-
SyBigEndianPack64(pOvfl->zData,pNew->pgno);
50615+
SyBigEndianPack64(pOvfl->zData,pNew->iPage);
5061650616
pEngine->pIo->xPageUnref(pOvfl);
5061750617
SyBigEndianPack64(pNew->zData,0); /* Next overflow page on the chain */
5061850618
pOvfl = pNew;
@@ -50823,8 +50823,8 @@ static int lhFindSlavePage(lhpage *pPage,sxu64 nAmount,sxu16 *pOfft,lhpage **ppS
5082350823
goto fail;
5082450824
}
5082550825
/* Reflect in the page header */
50826-
SyBigEndianPack64(&pSlave->pRaw->zData[2/*Cell offset*/+2/*Free block offset*/],pRaw->pgno);
50827-
pSlave->sHdr.iSlave = pRaw->pgno;
50826+
SyBigEndianPack64(&pSlave->pRaw->zData[2/*Cell offset*/+2/*Free block offset*/],pRaw->iPage);
50827+
pSlave->sHdr.iSlave = pRaw->iPage;
5082850828
/* All done */
5082950829
*ppSlave = pNew;
5083050830
return UNQLITE_OK;
@@ -51003,12 +51003,12 @@ static int lhSplit(lhpage *pTarget,int *pRetry)
5100351003
/* Install and write the logical map record */
5100451004
rc = lhMapWriteRecord(pEngine,
5100551005
pEngine->split_bucket + pEngine->max_split_bucket,
51006-
pRaw->pgno
51006+
pRaw->iPage
5100751007
);
5100851008
if( rc != UNQLITE_OK ){
5100951009
goto fail;
5101051010
}
51011-
if( pTarget->pRaw->pgno == pOld->pRaw->pgno ){
51011+
if( pTarget->pRaw->iPage == pOld->pRaw->iPage ){
5101251012
*pRetry = 1;
5101351013
}
5101451014
/* Perform the split */
@@ -51131,7 +51131,7 @@ static int lh_record_insert(
5113151131
rc = lhStoreCell(pPage,pKey,nKeyLen,pData,nDataLen,nHash,1);
5113251132
if( rc == UNQLITE_OK ){
5113351133
/* Install and write the logical map record */
51134-
rc = lhMapWriteRecord(pEngine,iBucket,pRaw->pgno);
51134+
rc = lhMapWriteRecord(pEngine,iBucket,pRaw->iPage);
5113551135
}
5113651136
pEngine->pIo->xPageUnref(pRaw);
5113751137
return rc;
@@ -51219,7 +51219,7 @@ static int lhash_write_header(lhash_kv_engine *pEngine,unqlite_page *pHeader)
5121951219
/* Initialize the bucket map */
5122051220
pMap = &pEngine->sPageMap;
5122151221
/* Fill in the structure */
51222-
pMap->iNum = pHeader->pgno;
51222+
pMap->iNum = pHeader->iPage;
5122351223
/* Next page in the bucket map */
5122451224
SyBigEndianPack64(zRaw,0);
5122551225
zRaw += 8;
@@ -55432,6 +55432,9 @@ UNQLITE_PRIVATE const unqlite_vfs * unqliteExportBuiltinVfs(void)
5543255432
**
5543355433
**
5543455434
*/
55435+
#ifndef NULL
55436+
#define NULL 0
55437+
#endif
5543555438
#define PAGER_OPEN 0
5543655439
#define PAGER_READER 1
5543755440
#define PAGER_WRITER_LOCKED 2

unqlite.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ struct unqlite_page
662662
{
663663
unsigned char *zData; /* Content of this page */
664664
void *pUserData; /* Extra content */
665-
pgno pgno; /* Page number for this page */
665+
pgno iPage; /* Page number for this page */
666666
};
667667
/*
668668
* UnQLite handle to the underlying Key/Value Storage Engine (See below).

0 commit comments

Comments
 (0)