aboutsummaryrefslogtreecommitdiff
path: root/src/test_malloc.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2008-08-04 20:13:26 +0000
committerdrh <drh@noemail.net>2008-08-04 20:13:26 +0000
commite9d1c720ee4e1a85a301588a02746a2bba37c8cd (patch)
tree3052a9804cc968535043c9ed124252377dd2fd93 /src/test_malloc.c
parent33a14781c8ba8ed7ee6aad07b801a530e8355a44 (diff)
downloadsqlite-e9d1c720ee4e1a85a301588a02746a2bba37c8cd.tar.gz
sqlite-e9d1c720ee4e1a85a301588a02746a2bba37c8cd.zip
Separate verbs of sqlite3_config() and sqlite3_db_config() into their
own namespaces. Allow SQLITE3_DBCONFIG_LOOKASIDE to specific an external memory buffer. (CVS 5536) FossilOrigin-Name: 5dd865da5e787c10ef4c9e96647724bfab9dea01
Diffstat (limited to 'src/test_malloc.c')
-rw-r--r--src/test_malloc.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/test_malloc.c b/src/test_malloc.c
index 8eb73d8e9..449cdb291 100644
--- a/src/test_malloc.c
+++ b/src/test_malloc.c
@@ -13,7 +13,7 @@
** This file contains code used to implement test interfaces to the
** memory allocation subsystem.
**
-** $Id: test_malloc.c,v 1.45 2008/08/01 16:31:14 drh Exp $
+** $Id: test_malloc.c,v 1.46 2008/08/04 20:13:27 drh Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
@@ -1005,8 +1005,11 @@ static int test_config_lookaside(
/*
-** Usage: sqlite3_db_config_lookaside CONNECTION SIZE COUNT
+** Usage: sqlite3_db_config_lookaside CONNECTION BUFID SIZE COUNT
**
+** There are two static buffers with BUFID 1 and 2. Each static buffer
+** is 10KB in size. A BUFID of 0 indicates that the buffer should be NULL
+** which will cause sqlite3_db_config() to allocate space on its own.
*/
static int test_db_config_lookaside(
void * clientData,
@@ -1017,15 +1020,25 @@ static int test_db_config_lookaside(
int rc;
int sz, cnt;
sqlite3 *db;
+ int bufid;
+ static char azBuf[2][10000];
int getDbPointer(Tcl_Interp*, const char*, sqlite3**);
- if( objc!=4 ){
- Tcl_WrongNumArgs(interp, 1, objv, "SIZE COUNT");
+ if( objc!=5 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "BUFID SIZE COUNT");
return TCL_ERROR;
}
if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
- if( Tcl_GetIntFromObj(interp, objv[2], &sz) ) return TCL_ERROR;
- if( Tcl_GetIntFromObj(interp, objv[3], &cnt) ) return TCL_ERROR;
- rc = sqlite3_db_config(db, SQLITE_CONFIG_LOOKASIDE, sz, cnt);
+ if( Tcl_GetIntFromObj(interp, objv[2], &bufid) ) return TCL_ERROR;
+ if( Tcl_GetIntFromObj(interp, objv[3], &sz) ) return TCL_ERROR;
+ if( Tcl_GetIntFromObj(interp, objv[4], &cnt) ) return TCL_ERROR;
+ if( bufid==0 ){
+ rc = sqlite3_db_config(db, SQLITE_DBCONFIG_LOOKASIDE, 0, sz, cnt);
+ }else if( bufid>=1 && bufid<=2 && sz*cnt<=sizeof(azBuf[0]) ){
+ rc = sqlite3_db_config(db, SQLITE_DBCONFIG_LOOKASIDE, azBuf[bufid], sz,cnt);
+ }else{
+ Tcl_AppendResult(interp, "illegal arguments - see documentation", (char*)0);
+ return TCL_ERROR;
+ }
Tcl_SetObjResult(interp, Tcl_NewIntObj(rc));
return TCL_OK;
}