1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-14 00:22:38 +03:00

Added new configuration options to query the low-level malloc interface

and to provide memory buffers for scratch, page-cache, and heap memory
allocators. (CVS 5231)

FossilOrigin-Name: e36201a352f832c97c5c0fcb872c1f094cac03d2
This commit is contained in:
drh
2008-06-18 13:27:46 +00:00
parent 1a9ed0b27a
commit 335897970c
5 changed files with 119 additions and 22 deletions

View File

@@ -14,7 +14,7 @@
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
** $Id: main.c,v 1.447 2008/06/18 09:45:56 danielk1977 Exp $
** $Id: main.c,v 1.448 2008/06/18 13:27:47 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -151,6 +151,12 @@ int sqlite3_config(int op, ...){
sqlite3Config.m = *va_arg(ap, sqlite3_mem_methods*);
break;
}
case SQLITE_CONFIG_GETMALLOC: {
/* Specify an alternative malloc implementation */
if( sqlite3Config.m.xMalloc==0 ) sqlite3MemSetDefault();
*va_arg(ap, sqlite3_mem_methods*) = sqlite3Config.m;
break;
}
case SQLITE_CONFIG_MUTEX: {
/* Specify an alternative mutex implementation */
sqlite3Config.mutex = *va_arg(ap, sqlite3_mutex_methods*);
@@ -166,6 +172,27 @@ int sqlite3_config(int op, ...){
sqlite3Config.bMemstat = va_arg(ap, int);
break;
}
case SQLITE_CONFIG_SCRATCH: {
/* Designate a buffer for scratch memory space */
sqlite3Config.pScratch = va_arg(ap, void*);
sqlite3Config.szScratch = va_arg(ap, int);
sqlite3Config.nScratch = va_arg(ap, int);
break;
}
case SQLITE_CONFIG_PAGECACHE: {
/* Designate a buffer for scratch memory space */
sqlite3Config.pPage = va_arg(ap, void*);
sqlite3Config.szPage = va_arg(ap, int);
sqlite3Config.nPage = va_arg(ap, int);
break;
}
case SQLITE_CONFIG_HEAP: {
/* Designate a buffer for scratch memory space */
sqlite3Config.pHeap = va_arg(ap, void*);
sqlite3Config.nHeap = va_arg(ap, int);
sqlite3Config.mnReq = va_arg(ap, int);
break;
}
default: {
rc = SQLITE_ERROR;
break;