mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-16 23:02:26 +03:00
Change a few selected functions to macros to speed things up. (CVS 4015)
FossilOrigin-Name: 93f811ec747f6a42daf9ee27cd8b013f248552a1
This commit is contained in:
18
src/malloc.c
18
src/malloc.c
@@ -12,7 +12,7 @@
|
||||
** Memory allocation functions used throughout sqlite.
|
||||
**
|
||||
**
|
||||
** $Id: malloc.c,v 1.1 2007/05/05 11:48:54 drh Exp $
|
||||
** $Id: malloc.c,v 1.2 2007/05/16 17:28:43 danielk1977 Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include "os.h"
|
||||
@@ -788,10 +788,10 @@ void sqlite3SetString(char **pz, ...){
|
||||
** then the connection error-code (the value returned by sqlite3_errcode())
|
||||
** is set to SQLITE_NOMEM.
|
||||
*/
|
||||
static int mallocHasFailed = 0;
|
||||
int sqlite3_mallocHasFailed = 0;
|
||||
int sqlite3ApiExit(sqlite3* db, int rc){
|
||||
if( sqlite3MallocFailed() ){
|
||||
mallocHasFailed = 0;
|
||||
sqlite3_mallocHasFailed = 0;
|
||||
sqlite3OsLeaveMutex();
|
||||
sqlite3Error(db, SQLITE_NOMEM, 0);
|
||||
rc = SQLITE_NOMEM;
|
||||
@@ -799,22 +799,14 @@ int sqlite3ApiExit(sqlite3* db, int rc){
|
||||
return rc & (db ? db->errMask : 0xff);
|
||||
}
|
||||
|
||||
/*
|
||||
** Return true is a malloc has failed in this thread since the last call
|
||||
** to sqlite3ApiExit(), or false otherwise.
|
||||
*/
|
||||
int sqlite3MallocFailed(){
|
||||
return (mallocHasFailed && sqlite3OsInMutex(1));
|
||||
}
|
||||
|
||||
/*
|
||||
** Set the "malloc has failed" condition to true for this thread.
|
||||
*/
|
||||
void sqlite3FailedMalloc(){
|
||||
if( !sqlite3MallocFailed() ){
|
||||
sqlite3OsEnterMutex();
|
||||
assert( mallocHasFailed==0 );
|
||||
mallocHasFailed = 1;
|
||||
assert( sqlite3_mallocHasFailed==0 );
|
||||
sqlite3_mallocHasFailed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user