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

Unified Diff: third_party/sqlite/src/src/mem1.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/mem0.c ('k') | third_party/sqlite/src/src/mem2.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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){
« no previous file with comments | « third_party/sqlite/src/src/mem0.c ('k') | third_party/sqlite/src/src/mem2.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698