aboutsummaryrefslogtreecommitdiff
path: root/src/mem1.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mem1.c')
-rw-r--r--src/mem1.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/src/mem1.c b/src/mem1.c
index 67dd47453..558eed847 100644
--- a/src/mem1.c
+++ b/src/mem1.c
@@ -42,6 +42,8 @@ static void *sqlite3MemMalloc(int nByte){
if( p ){
p[0] = nByte;
p++;
+ }else{
+ sqlite3_log(SQLITE_NOMEM, "failed to allocate %u bytes of memory", nByte);
}
return (void *)p;
}
@@ -62,6 +64,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().
**
@@ -80,23 +94,15 @@ static void *sqlite3MemRealloc(void *pPrior, int nByte){
if( p ){
p[0] = nByte;
p++;
+ }else{
+ 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){