Index: third_party/sqlite/src/src/mem1.c |
diff --git a/third_party/sqlite/src/src/mem1.c b/third_party/sqlite/src/src/mem1.c |
index e3b886341c21a69096858df392645364b5aa97f0..61fbf4bdbab2ff9935ef90b12deabbef1f3cf9b9 100644 |
--- a/third_party/sqlite/src/src/mem1.c |
+++ b/third_party/sqlite/src/src/mem1.c |
@@ -16,8 +16,6 @@ |
** |
** This file contains implementations of the low-level memory allocation |
** routines specified in the sqlite3_mem_methods object. |
-** |
-** $Id: mem1.c,v 1.30 2009/03/23 04:33:33 danielk1977 Exp $ |
*/ |
#include "sqliteInt.h" |
@@ -44,6 +42,9 @@ static void *sqlite3MemMalloc(int nByte){ |
if( p ){ |
p[0] = nByte; |
p++; |
+ }else{ |
+ testcase( sqlite3GlobalConfig.xLog!=0 ); |
+ sqlite3_log(SQLITE_NOMEM, "failed to allocate %u bytes of memory", nByte); |
} |
return (void *)p; |
} |
@@ -64,6 +65,18 @@ static void sqlite3MemFree(void *pPrior){ |
} |
/* |
+** Report the allocated size of a prior return from xMalloc() |
+** or xRealloc(). |
+*/ |
+static int sqlite3MemSize(void *pPrior){ |
+ sqlite3_int64 *p; |
+ if( pPrior==0 ) return 0; |
+ p = (sqlite3_int64*)pPrior; |
+ p--; |
+ return (int)p[0]; |
+} |
+ |
+/* |
** Like realloc(). Resize an allocation previously obtained from |
** sqlite3MemMalloc(). |
** |
@@ -76,30 +89,22 @@ static void sqlite3MemFree(void *pPrior){ |
static void *sqlite3MemRealloc(void *pPrior, int nByte){ |
sqlite3_int64 *p = (sqlite3_int64*)pPrior; |
assert( pPrior!=0 && nByte>0 ); |
- nByte = ROUND8(nByte); |
- p = (sqlite3_int64*)pPrior; |
+ assert( nByte==ROUND8(nByte) ); /* EV: R-46199-30249 */ |
p--; |
p = realloc(p, nByte+8 ); |
if( p ){ |
p[0] = nByte; |
p++; |
+ }else{ |
+ testcase( sqlite3GlobalConfig.xLog!=0 ); |
+ sqlite3_log(SQLITE_NOMEM, |
+ "failed memory resize %u to %u bytes", |
+ sqlite3MemSize(pPrior), nByte); |
} |
return (void*)p; |
} |
/* |
-** Report the allocated size of a prior return from xMalloc() |
-** or xRealloc(). |
-*/ |
-static int sqlite3MemSize(void *pPrior){ |
- sqlite3_int64 *p; |
- if( pPrior==0 ) return 0; |
- p = (sqlite3_int64*)pPrior; |
- p--; |
- return (int)p[0]; |
-} |
- |
-/* |
** Round up a request size to the next valid allocation size. |
*/ |
static int sqlite3MemRoundup(int n){ |