aboutsummaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/util.c b/src/util.c
index ab7e1420c..36cf5dc8d 100644
--- a/src/util.c
+++ b/src/util.c
@@ -14,7 +14,7 @@
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
-** $Id: util.c,v 1.173 2006/01/17 15:36:32 danielk1977 Exp $
+** $Id: util.c,v 1.174 2006/01/18 15:25:18 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "os.h"
@@ -1336,15 +1336,28 @@ void sqlite3ReleaseThreadData(){
}
/*
-** Clear the "mallocFailed" flag. This should be invoked before exiting any
-** entry points that may have called sqliteMalloc().
+** This function must be called before exiting any API function (i.e.
+** returning control to the user) that has called sqlite3Malloc or
+** sqlite3Realloc.
+**
+** The returned value is normally a copy of the second argument to this
+** function. However, if a malloc() failure has occured since the previous
+** invocation SQLITE_NOMEM is returned instead.
+**
+** If the first argument, db, is not NULL and a malloc() error has occured,
+** then the connection error-code (the value returned by sqlite3_errcode())
+** is set to SQLITE_NOMEM.
*/
-void sqlite3MallocClearFailed(){
+int sqlite3ApiExit(sqlite3* db, int rc){
ThreadData *pTd = sqlite3OsThreadSpecificData(0);
if( pTd && pTd->mallocFailed ){
pTd->mallocFailed = 0;
- sqlite3OsThreadSpecificData(0);
+ if( db ){
+ sqlite3Error(db, SQLITE_NOMEM, 0);
+ }
+ return SQLITE_NOMEM;
}
+ return rc;
}
#ifdef SQLITE_MEMDEBUG