aboutsummaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authordanielk1977 <danielk1977@noemail.net>2006-01-18 15:25:17 +0000
committerdanielk1977 <danielk1977@noemail.net>2006-01-18 15:25:17 +0000
commit54f0198e47ef06ee7a4326ccc51d6a21ce8914d2 (patch)
treea8141acd8c4016502372e39d02c6603935ae5018 /src/util.c
parent332b1feaf1067f317c2ee91ec39de1ed37e170c9 (diff)
downloadsqlite-54f0198e47ef06ee7a4326ccc51d6a21ce8914d2.tar.gz
sqlite-54f0198e47ef06ee7a4326ccc51d6a21ce8914d2.zip
Change sqlite3MallocClearFailed() calls to sqlite3ApiExit(), a better API. (CVS 2970)
FossilOrigin-Name: e0b022e5b2bfd272b4e25cd7a7b472206a118bbe
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