mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-09 14:21:03 +03:00
Change sqlite3MallocClearFailed() calls to sqlite3ApiExit(), a better API. (CVS 2970)
FossilOrigin-Name: e0b022e5b2bfd272b4e25cd7a7b472206a118bbe
This commit is contained in:
23
src/util.c
23
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
|
||||
|
||||
Reference in New Issue
Block a user