Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Unified Diff: third_party/sqlite/src/src/test_malloc.c

Issue 6990047: Import SQLite 3.7.6.3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/sqlite/src/src/test_loadext.c ('k') | third_party/sqlite/src/src/test_md5.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/sqlite/src/src/test_malloc.c
diff --git a/third_party/sqlite/src/src/test_malloc.c b/third_party/sqlite/src/src/test_malloc.c
index ff2ced3295af90dfed73e6e026fba1f9d240468f..c63ded7035bd121004972cfe967f1b25e1fb96cc 100644
--- a/third_party/sqlite/src/src/test_malloc.c
+++ b/third_party/sqlite/src/src/test_malloc.c
@@ -12,8 +12,6 @@
**
** This file contains code used to implement test interfaces to the
** memory allocation subsystem.
-**
-** $Id: test_malloc.c,v 1.55 2009/07/01 18:09:02 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
@@ -730,7 +728,10 @@ static int test_memdebug_settitle(
return TCL_OK;
}
-#define MALLOC_LOG_FRAMES 10
+#define MALLOC_LOG_FRAMES 10
+#define MALLOC_LOG_KEYINTS ( \
+ 10 * ((sizeof(int)>=sizeof(void*)) ? 1 : sizeof(void*)/sizeof(int)) \
+)
static Tcl_HashTable aMallocLog;
static int mallocLogEnabled = 0;
@@ -747,8 +748,8 @@ static void test_memdebug_callback(int nByte, int nFrame, void **aFrame){
Tcl_HashEntry *pEntry;
int isNew;
- int aKey[MALLOC_LOG_FRAMES];
- int nKey = sizeof(int)*MALLOC_LOG_FRAMES;
+ int aKey[MALLOC_LOG_KEYINTS];
+ int nKey = sizeof(int)*MALLOC_LOG_KEYINTS;
memset(aKey, 0, nKey);
if( (sizeof(void*)*nFrame)<nKey ){
@@ -783,7 +784,7 @@ static void test_memdebug_log_clear(void){
Tcl_Free((char *)pLog);
}
Tcl_DeleteHashTable(&aMallocLog);
- Tcl_InitHashTable(&aMallocLog, MALLOC_LOG_FRAMES);
+ Tcl_InitHashTable(&aMallocLog, MALLOC_LOG_KEYINTS);
}
static int test_memdebug_log(
@@ -806,7 +807,7 @@ static int test_memdebug_log(
void (*xBacktrace)(int, int, void **));
sqlite3MemdebugBacktraceCallback(test_memdebug_callback);
#endif
- Tcl_InitHashTable(&aMallocLog, MALLOC_LOG_FRAMES);
+ Tcl_InitHashTable(&aMallocLog, MALLOC_LOG_KEYINTS);
isInit = 1;
}
@@ -829,7 +830,7 @@ static int test_memdebug_log(
Tcl_HashEntry *pEntry;
Tcl_Obj *pRet = Tcl_NewObj();
- assert(sizeof(int)==sizeof(void*));
+ assert(sizeof(Tcl_WideInt)>=sizeof(void*));
for(
pEntry=Tcl_FirstHashEntry(&aMallocLog, &search);
@@ -838,13 +839,13 @@ static int test_memdebug_log(
){
Tcl_Obj *apElem[MALLOC_LOG_FRAMES+2];
MallocLog *pLog = (MallocLog *)Tcl_GetHashValue(pEntry);
- int *aKey = (int *)Tcl_GetHashKey(&aMallocLog, pEntry);
+ Tcl_WideInt *aKey = (Tcl_WideInt *)Tcl_GetHashKey(&aMallocLog, pEntry);
int ii;
apElem[0] = Tcl_NewIntObj(pLog->nCall);
apElem[1] = Tcl_NewIntObj(pLog->nByte);
for(ii=0; ii<MALLOC_LOG_FRAMES; ii++){
- apElem[ii+2] = Tcl_NewIntObj(aKey[ii]);
+ apElem[ii+2] = Tcl_NewWideIntObj(aKey[ii]);
}
Tcl_ListObjAppendElement(interp, pRet,
@@ -1239,6 +1240,7 @@ static int test_status(
{ "SQLITE_STATUS_SCRATCH_OVERFLOW", SQLITE_STATUS_SCRATCH_OVERFLOW },
{ "SQLITE_STATUS_SCRATCH_SIZE", SQLITE_STATUS_SCRATCH_SIZE },
{ "SQLITE_STATUS_PARSER_STACK", SQLITE_STATUS_PARSER_STACK },
+ { "SQLITE_STATUS_MALLOC_COUNT", SQLITE_STATUS_MALLOC_COUNT },
};
Tcl_Obj *pResult;
if( objc!=3 ){
@@ -1288,7 +1290,13 @@ static int test_db_status(
const char *zName;
int op;
} aOp[] = {
- { "SQLITE_DBSTATUS_LOOKASIDE_USED", SQLITE_DBSTATUS_LOOKASIDE_USED },
+ { "LOOKASIDE_USED", SQLITE_DBSTATUS_LOOKASIDE_USED },
+ { "CACHE_USED", SQLITE_DBSTATUS_CACHE_USED },
+ { "SCHEMA_USED", SQLITE_DBSTATUS_SCHEMA_USED },
+ { "STMT_USED", SQLITE_DBSTATUS_STMT_USED },
+ { "LOOKASIDE_HIT", SQLITE_DBSTATUS_LOOKASIDE_HIT },
+ { "LOOKASIDE_MISS_SIZE", SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE },
+ { "LOOKASIDE_MISS_FULL", SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL }
};
Tcl_Obj *pResult;
if( objc!=4 ){
@@ -1297,6 +1305,8 @@ static int test_db_status(
}
if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
zOpName = Tcl_GetString(objv[2]);
+ if( memcmp(zOpName, "SQLITE_", 7)==0 ) zOpName += 7;
+ if( memcmp(zOpName, "DBSTATUS_", 9)==0 ) zOpName += 9;
for(i=0; i<ArraySize(aOp); i++){
if( strcmp(aOp[i].zName, zOpName)==0 ){
op = aOp[i].op;
@@ -1360,6 +1370,25 @@ static int test_install_memsys3(
return TCL_OK;
}
+static int test_vfs_oom_test(
+ void * clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+ extern int sqlite3_memdebug_vfs_oom_test;
+ if( objc>2 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "?INTEGER?");
+ return TCL_ERROR;
+ }else if( objc==2 ){
+ int iNew;
+ if( Tcl_GetIntFromObj(interp, objv[1], &iNew) ) return TCL_ERROR;
+ sqlite3_memdebug_vfs_oom_test = iNew;
+ }
+ Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_memdebug_vfs_oom_test));
+ return TCL_OK;
+}
+
/*
** Register commands with the TCL interpreter.
*/
@@ -1397,6 +1426,7 @@ int Sqlitetest_malloc_Init(Tcl_Interp *interp){
{ "sqlite3_dump_memsys3", test_dump_memsys3 ,3 },
{ "sqlite3_dump_memsys5", test_dump_memsys3 ,5 },
{ "sqlite3_install_memsys3", test_install_memsys3 ,0 },
+ { "sqlite3_memdebug_vfs_oom_test", test_vfs_oom_test ,0 },
};
int i;
for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){
« no previous file with comments | « third_party/sqlite/src/src/test_loadext.c ('k') | third_party/sqlite/src/src/test_md5.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698