Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Unified Diff: third_party/sqlite/src/src/mem5.c

Issue 6990047: Import SQLite 3.7.6.3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/sqlite/src/src/mem3.c ('k') | third_party/sqlite/src/src/memjournal.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/sqlite/src/src/mem5.c
diff --git a/third_party/sqlite/src/src/mem5.c b/third_party/sqlite/src/src/mem5.c
index 3fe04e24552cd4d5724e7398d9547fc1fe7a218f..783cef6176c59cbf30914631095a1a54f4e42e08 100644
--- a/third_party/sqlite/src/src/mem5.c
+++ b/third_party/sqlite/src/src/mem5.c
@@ -127,7 +127,7 @@ static SQLITE_WSD struct Mem5Global {
*/
u8 *aCtrl;
-} mem5 = { 0 };
+} mem5;
/*
** Access the static variable through a macro for SQLITE_OMIT_WSD
@@ -268,7 +268,11 @@ static void *memsys5MallocUnsafe(int nByte){
** two in order to create a new free block of size iLogsize.
*/
for(iBin=iLogsize; mem5.aiFreelist[iBin]<0 && iBin<=LOGMAX; iBin++){}
- if( iBin>LOGMAX ) return 0;
+ if( iBin>LOGMAX ){
+ testcase( sqlite3GlobalConfig.xLog!=0 );
+ sqlite3_log(SQLITE_NOMEM, "failed to allocate %u bytes", nByte);
+ return 0;
+ }
i = memsys5UnlinkFirst(iBin);
while( iBin>iLogsize ){
int newSize;
@@ -391,7 +395,7 @@ static void *memsys5Realloc(void *pPrior, int nBytes){
int nOld;
void *p;
assert( pPrior!=0 );
- assert( (nBytes&(nBytes-1))==0 );
+ assert( (nBytes&(nBytes-1))==0 ); /* EV: R-46199-30249 */
assert( nBytes>=0 );
if( nBytes==0 ){
return 0;
@@ -438,7 +442,7 @@ static int memsys5Roundup(int n){
*/
static int memsys5Log(int iValue){
int iLog;
- for(iLog=0; (1<<iLog)<iValue; iLog++);
+ for(iLog=0; (iLog<(int)((sizeof(int)*8)-1)) && (1<<iLog)<iValue; iLog++);
return iLog;
}
@@ -469,6 +473,7 @@ static int memsys5Init(void *NotUsed){
zByte = (u8*)sqlite3GlobalConfig.pHeap;
assert( zByte!=0 ); /* sqlite3_config() does not allow otherwise */
+ /* boundaries on sqlite3GlobalConfig.mnReq are enforced in sqlite3_config() */
nMinLog = memsys5Log(sqlite3GlobalConfig.mnReq);
mem5.szAtom = (1<<nMinLog);
while( (int)sizeof(Mem5Link)>mem5.szAtom ){
« no previous file with comments | « third_party/sqlite/src/src/mem3.c ('k') | third_party/sqlite/src/src/memjournal.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698