diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/malloc.c | 6 | ||||
-rw-r--r-- | src/printf.c | 2 | ||||
-rw-r--r-- | src/test1.c | 13 |
3 files changed, 15 insertions, 6 deletions
diff --git a/src/malloc.c b/src/malloc.c index e8124a34d..2ae3a55ad 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -12,7 +12,7 @@ ** Memory allocation functions used throughout sqlite. ** ** -** $Id: malloc.c,v 1.2 2007/05/16 17:28:43 danielk1977 Exp $ +** $Id: malloc.c,v 1.3 2007/06/15 20:29:20 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -203,6 +203,7 @@ int sqlite3_mallocDisallowed = 0; /* assert() in sqlite3Malloc() if set */ int sqlite3_isFail = 0; /* True if all malloc calls should fail */ const char *sqlite3_zFile = 0; /* Filename to associate debug info with */ int sqlite3_iLine = 0; /* Line number for debug info */ +int sqlite3_mallocfail_trace = 0; /* Print a msg on malloc fail if true */ /* ** Check for a simulated memory allocation failure. Return true if @@ -217,6 +218,9 @@ int sqlite3TestMallocFail(){ if( sqlite3_iMallocFail==0 ){ sqlite3_iMallocFail = sqlite3_iMallocReset; sqlite3_isFail = 1; + if( sqlite3_mallocfail_trace ){ + sqlite3DebugPrintf("###_malloc_fails_###\n"); + } return 1; } } diff --git a/src/printf.c b/src/printf.c index 92073991d..e910650fe 100644 --- a/src/printf.c +++ b/src/printf.c @@ -862,7 +862,7 @@ char *sqlite3_snprintf(int n, char *zBuf, const char *zFormat, ...){ return z; } -#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG) +#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG) || defined(SQLITE_MEMDEBUG) /* ** A version of printf() that understands %lld. Used for debugging. ** The printf() built into some versions of windows does not understand %lld diff --git a/src/test1.c b/src/test1.c index 14c1120ce..1454cd64e 100644 --- a/src/test1.c +++ b/src/test1.c @@ -13,7 +13,7 @@ ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** -** $Id: test1.c,v 1.255 2007/06/15 18:53:15 drh Exp $ +** $Id: test1.c,v 1.256 2007/06/15 20:29:20 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" @@ -4445,7 +4445,6 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ extern int sqlite3_sync_count, sqlite3_fullsync_count; extern int sqlite3_opentemp_count; extern int sqlite3_memUsed; - extern char *sqlite3_malloc_id; extern int sqlite3_memMax; extern int sqlite3_like_count; extern int sqlite3_tsd_count; @@ -4516,8 +4515,14 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ (char*)&pzNeededCollation, TCL_LINK_STRING|TCL_LINK_READ_ONLY); #endif #ifdef SQLITE_MEMDEBUG - Tcl_LinkVar(interp, "sqlite_malloc_id", - (char*)&sqlite3_malloc_id, TCL_LINK_STRING); + { + extern char *sqlite3_malloc_id; + extern int sqlite3_mallocfail_trace; + Tcl_LinkVar(interp, "sqlite_malloc_id", + (char*)&sqlite3_malloc_id, TCL_LINK_STRING); + Tcl_LinkVar(interp, "sqlite3_mallocfail_trace", + (char*)&sqlite3_mallocfail_trace, TCL_LINK_INT); + } #endif #if OS_WIN Tcl_LinkVar(interp, "sqlite_os_type", |