Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Avoid signed/unsigned comparison warnings in bitvec.c by changing the types of loop variables to unsigned int. (CVS 5880) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
da869446c53ec6ed769bba01cdc2b6fd |
User & Date: | drh 2008-11-11 15:48:48.000 |
Context
2008-11-11
| ||
17:36 | Fixed crash in integrity_check with corrupt content offset size in page header. (CVS 5881) (check-in: 0659a666ff user: shane tags: trunk) | |
15:48 | Avoid signed/unsigned comparison warnings in bitvec.c by changing the types of loop variables to unsigned int. (CVS 5880) (check-in: da869446c5 user: drh tags: trunk) | |
00:36 | When an assignment occurs in a boolean, always test the result using "!=0" to avoid confusion and make it clear that assignment is intended, not an equality test. Ticket #3491. (CVS 5879) (check-in: 89ee5295bd user: drh tags: trunk) | |
Changes
Changes to src/bitvec.c.
︙ | ︙ | |||
30 31 32 33 34 35 36 | ** Clear operations are exceedingly rare. There are usually between ** 5 and 500 set operations per Bitvec object, though the number of sets can ** sometimes grow into tens of thousands or larger. The size of the ** Bitvec object is the number of pages in the database file at the ** start of a transaction, and is thus usually less than a few thousand, ** but can be as large as 2 billion for a really big database. ** | | | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | ** Clear operations are exceedingly rare. There are usually between ** 5 and 500 set operations per Bitvec object, though the number of sets can ** sometimes grow into tens of thousands or larger. The size of the ** Bitvec object is the number of pages in the database file at the ** start of a transaction, and is thus usually less than a few thousand, ** but can be as large as 2 billion for a really big database. ** ** @(#) $Id: bitvec.c,v 1.8 2008/11/11 15:48:48 drh Exp $ */ #include "sqliteInt.h" #define BITVEC_SZ 512 /* Round the union size down to the nearest pointer boundary, since that's how ** it will be aligned within the Bitvec struct. */ #define BITVEC_USIZE (((BITVEC_SZ-12)/sizeof(Bitvec*))*sizeof(Bitvec*)) |
︙ | ︙ | |||
161 162 163 164 165 166 167 | while( p->u.aHash[h] ){ if( p->u.aHash[h]==i ) return SQLITE_OK; h++; if( h==BITVEC_NINT ) h = 0; } p->nSet++; if( p->nSet>=BITVEC_MXHASH ){ | > | | 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | while( p->u.aHash[h] ){ if( p->u.aHash[h]==i ) return SQLITE_OK; h++; if( h==BITVEC_NINT ) h = 0; } p->nSet++; if( p->nSet>=BITVEC_MXHASH ){ unsigned int j; int rc; u32 aiValues[BITVEC_NINT]; memcpy(aiValues, p->u.aHash, sizeof(aiValues)); memset(p->u.apSub, 0, sizeof(p->u.apSub[0])*BITVEC_NPTR); p->iDivisor = (p->iSize + BITVEC_NPTR - 1)/BITVEC_NPTR; rc = sqlite3BitvecSet(p, i); for(j=0; j<BITVEC_NINT; j++){ if( aiValues[j] ) rc |= sqlite3BitvecSet(p, aiValues[j]); |
︙ | ︙ | |||
193 194 195 196 197 198 199 | }else if( p->iDivisor ){ u32 bin = (i-1)/p->iDivisor; i = (i-1)%p->iDivisor + 1; if( p->u.apSub[bin] ){ sqlite3BitvecClear(p->u.apSub[bin], i); } }else{ | | | | 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | }else if( p->iDivisor ){ u32 bin = (i-1)/p->iDivisor; i = (i-1)%p->iDivisor + 1; if( p->u.apSub[bin] ){ sqlite3BitvecClear(p->u.apSub[bin], i); } }else{ unsigned int j; u32 aiValues[BITVEC_NINT]; memcpy(aiValues, p->u.aHash, sizeof(aiValues)); memset(p->u.aHash, 0, sizeof(p->u.aHash[0])*BITVEC_NINT); p->nSet = 0; for(j=0; j<BITVEC_NINT; j++){ if( aiValues[j] && aiValues[j]!=i ){ sqlite3BitvecSet(p, aiValues[j]); } } } } /* ** Destroy a bitmap object. Reclaim all memory used. */ void sqlite3BitvecDestroy(Bitvec *p){ if( p==0 ) return; if( p->iDivisor ){ unsigned int i; for(i=0; i<BITVEC_NPTR; i++){ sqlite3BitvecDestroy(p->u.apSub[i]); } } sqlite3_free(p); } |
︙ | ︙ |