1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Remove the rarely-used scratch memory allocator. This makes the code smaller,

faster, and easier to maintain.  In place of the scratch allocator, add the
SQLITE_CONFIG_SMALL_MALLOC configuration option that provides a hint to SQLite
that large memory allocations should be avoided.

FossilOrigin-Name: 54b000246cfb5c7b8adb61a17357ef5a49adddde9e48e8937834d5ba0beb8a6b
This commit is contained in:
drh
2017-08-28 15:51:35 +00:00
parent b3c4523c58
commit b2a0f75c06
19 changed files with 71 additions and 517 deletions

View File

@@ -887,46 +887,6 @@ static int SQLITE_TCLAPI test_memdebug_log(
return TCL_OK;
}
/*
** Usage: sqlite3_config_scratch SIZE N
**
** Set the scratch memory buffer using SQLITE_CONFIG_SCRATCH.
** The buffer is static and is of limited size. N might be
** adjusted downward as needed to accommodate the requested size.
** The revised value of N is returned.
**
** A negative SIZE causes the buffer pointer to be NULL.
*/
static int SQLITE_TCLAPI test_config_scratch(
void * clientData,
Tcl_Interp *interp,
int objc,
Tcl_Obj *CONST objv[]
){
int sz, N, rc;
Tcl_Obj *pResult;
static char *buf = 0;
if( objc!=3 ){
Tcl_WrongNumArgs(interp, 1, objv, "SIZE N");
return TCL_ERROR;
}
if( Tcl_GetIntFromObj(interp, objv[1], &sz) ) return TCL_ERROR;
if( Tcl_GetIntFromObj(interp, objv[2], &N) ) return TCL_ERROR;
free(buf);
if( sz<0 ){
buf = 0;
rc = sqlite3_config(SQLITE_CONFIG_SCRATCH, (void*)0, 0, 0);
}else{
buf = malloc( sz*N + 1 );
rc = sqlite3_config(SQLITE_CONFIG_SCRATCH, buf, sz, N);
}
pResult = Tcl_NewObj();
Tcl_ListObjAppendElement(0, pResult, Tcl_NewIntObj(rc));
Tcl_ListObjAppendElement(0, pResult, Tcl_NewIntObj(N));
Tcl_SetObjResult(interp, pResult);
return TCL_OK;
}
/*
** Usage: sqlite3_config_pagecache SIZE N
**
@@ -1538,7 +1498,6 @@ int Sqlitetest_malloc_Init(Tcl_Interp *interp){
{ "sqlite3_memdebug_settitle", test_memdebug_settitle ,0 },
{ "sqlite3_memdebug_malloc_count", test_memdebug_malloc_count ,0 },
{ "sqlite3_memdebug_log", test_memdebug_log ,0 },
{ "sqlite3_config_scratch", test_config_scratch ,0 },
{ "sqlite3_config_pagecache", test_config_pagecache ,0 },
{ "sqlite3_config_alt_pcache", test_alt_pcache ,0 },
{ "sqlite3_status", test_status ,0 },