aboutsummaryrefslogtreecommitdiff
path: root/src/shell.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2010-12-17 14:03:01 +0000
committerdrh <drh@noemail.net>2010-12-17 14:03:01 +0000
commit9c88d68988afd24e1ee607deef5531115a2c95f7 (patch)
treec076a957881e9db77cc5fb4fa42306357567b3c9 /src/shell.c
parentcd2f58b3741d744b68803ec79a923e4df8bb2d04 (diff)
downloadsqlite-9c88d68988afd24e1ee607deef5531115a2c95f7.tar.gz
sqlite-9c88d68988afd24e1ee607deef5531115a2c95f7.zip
Add the "-heap" option to the command-line shell - to allocate a fixed heap
for use with SQLITE_ENABLE_MEMSYS5. FossilOrigin-Name: 74fff692345fed4b247e2b34c1e63b4d50cddfd4
Diffstat (limited to 'src/shell.c')
-rw-r--r--src/shell.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/shell.c b/src/shell.c
index 3fd0db368..0609e4231 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -2542,6 +2542,7 @@ int main(int argc, char **argv){
/* Do an initial pass through the command-line argument to locate
** the name of the database file, the name of the initialization file,
+ ** the size of the alternative malloc heap,
** and the first command to execute.
*/
for(i=1; i<argc-1; i++){
@@ -2560,6 +2561,22 @@ int main(int argc, char **argv){
*/
}else if( strcmp(argv[i],"-batch")==0 ){
stdin_is_interactive = 0;
+ }else if( strcmp(argv[i],"-heap")==0 ){
+ int j, c;
+ const char *zSize;
+ sqlite3_int64 szHeap;
+
+ zSize = argv[++i];
+ szHeap = atoi(zSize);
+ for(j=0; (c = zSize[j])!=0; j++){
+ if( c=='M' ){ szHeap *= 1000000; break; }
+ if( c=='K' ){ szHeap *= 1000; break; }
+ if( c=='G' ){ szHeap *= 1000000000; break; }
+ }
+ if( szHeap>0x7fff0000 ) szHeap = 0x7fff0000;
+#if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5)
+ sqlite3_config(SQLITE_CONFIG_HEAP, malloc((int)szHeap), (int)szHeap, 64);
+#endif
}
}
if( i<argc ){
@@ -2666,6 +2683,8 @@ int main(int argc, char **argv){
stdin_is_interactive = 1;
}else if( strcmp(z,"-batch")==0 ){
stdin_is_interactive = 0;
+ }else if( strcmp(z,"-heap")==0 ){
+ i++;
}else if( strcmp(z,"-help")==0 || strcmp(z, "--help")==0 ){
usage(1);
}else{