]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add the new memory allocator to the amalgamation. Improvements to
authordrh <drh@noemail.net>
Sat, 20 Oct 2007 16:36:31 +0000 (16:36 +0000)
committerdrh <drh@noemail.net>
Sat, 20 Oct 2007 16:36:31 +0000 (16:36 +0000)
out-of-memory handling. (CVS 4498)

FossilOrigin-Name: b58c2b37a5deb19ce0ef78629989016743a46bb3

manifest
manifest.uuid
src/malloc.c
src/mem3.c
tool/mksqlite3c.tcl

index 65fa40dfaa99bed02f721ba2b95301e8d0826527..f83016baf1e95af5d8e7e5fa6e35b075c376b643 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Bug\sfix\sin\sthe\srealloc\salgorithm\sof\sthe\sstatic\smemory\sallocator.\s(CVS\s4497)
-D 2007-10-20T16:11:39
+C Add\sthe\snew\smemory\sallocator\sto\sthe\samalgamation.\s\sImprovements\sto\nout-of-memory\shandling.\s(CVS\s4498)
+D 2007-10-20T16:36:31
 F Makefile.in 30c7e3ba426ddb253b8ef037d1873425da6009a8
 F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -100,11 +100,11 @@ F src/legacy.c 4ac53191fad2e3c4d59bde1228879b2dc5a96d66
 F src/limits.h 71ab25f17e35e0a9f3f6f234b8ed49cc56731d35
 F src/loadext.c 124e566563d1c03e68e1396cb44df9870612c6e9
 F src/main.c 994a6b6914d91dc6dea5012667ec0a52e74d3bca
-F src/malloc.c de4e77fe70a9a0ac47a1c3a874422b107231bf31
+F src/malloc.c 60e392a4c12c839517f9b0db7b995f825444fb35
 F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217
 F src/mem1.c cacb202bc379da10d69aa66d497c0ea7bd9cd8a5
 F src/mem2.c 3f669b5e20975a5a2ca392aca891cd686e22b097
-F src/mem3.c 232f658b5919a979e894817e8d9a8047cc01738a
+F src/mem3.c df13c608e8dfb54f62e3448eb126e760aecbacf1
 F src/mutex.c 3259f62c2429967aee6dc112117a6d2f499ef061
 F src/mutex.h 079fa6fe9da18ceb89e79012c010594c6672addb
 F src/mutex_os2.c 7fe4773e98ed74a63b2e54fc557929eb155f6269
@@ -512,7 +512,7 @@ F tool/memleak2.awk 9cc20c8e8f3c675efac71ea0721ee6874a1566e8
 F tool/memleak3.tcl 7707006ee908cffff210c98158788d85bb3fcdbf
 F tool/mkkeywordhash.c ef93810fc41fb3d3dbacf9a33a29be88ea99ffa9
 F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x
-F tool/mksqlite3c.tcl 1b2fc352849823600fea9474245591e96733e557
+F tool/mksqlite3c.tcl 48778943a2fc83a4fdcbb3e109706b4b8e1b135a
 F tool/mksqlite3internalh.tcl 47737a925fb02fce43e2c0a14b3cc17574a4d44a
 F tool/omittest.tcl 7d1fdf469e2f4d175f70c36e469db64a1626fabb
 F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c
@@ -582,7 +582,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P ca51b2f54076fcf73a8857aecf4b45d66ef0c7b6
-R 149041cc2a0cdac1aeaffd2ccb597c27
+P 50db16be5025f6d5efc51e3354615059da7e8611
+R 9881665fdb8e4b9770ed547fbe8fa687
 U drh
-Z c7cecaa706d7ed7726d405d4a3f2983e
+Z fb42a97e45f6a24233932545382ee686
index f8b380543bae76a4f9ab58d2dbf7b72ff9c198be..56a7caf4b20fac1e0ddbc8fb55614ad9a255e181 100644 (file)
@@ -1 +1 @@
-50db16be5025f6d5efc51e3354615059da7e8611
\ No newline at end of file
+b58c2b37a5deb19ce0ef78629989016743a46bb3
\ No newline at end of file
index bc321ab9ae0efd389de74ccfb66c7756eead51da..a04734868bb1a27a8c80f6a46de9e2946a3342aa 100644 (file)
@@ -12,7 +12,7 @@
 ** Memory allocation functions used throughout sqlite.
 **
 **
-** $Id: malloc.c,v 1.13 2007/08/29 14:06:23 danielk1977 Exp $
+** $Id: malloc.c,v 1.14 2007/10/20 16:36:31 drh Exp $
 */
 #include "sqliteInt.h"
 #include <stdarg.h>
@@ -237,4 +237,3 @@ int sqlite3ApiExit(sqlite3* db, int rc){
   }
   return rc & (db ? db->errMask : 0xff);
 }
index 4b6fcf6c61e9702b6b39a27d6c53267992bc63a1..8cbafe37acfe5430c30efea0afffcb0ee7d9b0bc 100644 (file)
@@ -20,7 +20,7 @@
 ** This version of the memory allocation subsystem is used if
 ** and only if SQLITE_MEMORY_SIZE is defined.
 **
-** $Id: mem3.c,v 1.4 2007/10/20 16:11:39 drh Exp $
+** $Id: mem3.c,v 1.5 2007/10/20 16:36:31 drh Exp $
 */
 
 /*
@@ -372,6 +372,7 @@ static void memsys3Merge(int *pRoot){
 static void *memsys3Malloc(int nByte){
   int i;
   int nBlock;
+  int toFree;
 
   assert( sizeof(Mem3Block)==8 );
   if( nByte<=0 ){
@@ -418,22 +419,24 @@ static void *memsys3Malloc(int nByte){
   ** of the end of the master chunk.  This step happens very
   ** rarely (we hope!)
   */
-  memsys3OutOfMemory(nBlock*16);
-  if( mem.iMaster ){
-    memsys3Link(mem.iMaster);
-    mem.iMaster = 0;
-    mem.szMaster = 0;
-  }
-  for(i=0; i<N_HASH; i++){
-    memsys3Merge(&mem.aiHash[i]);
-  }
-  for(i=0; i<MX_SMALL-1; i++){
-    memsys3Merge(&mem.aiSmall[i]);
-  }
-  if( mem.szMaster ){
-    memsys3Unlink(mem.iMaster);
-    if( mem.szMaster>=nBlock ){
-      return memsys3FromMaster(nBlock);
+  for(toFree=nBlock*16; toFree<SQLITE_MEMORY_SIZE*2; toFree *= 2){
+    memsys3OutOfMemory(toFree);
+    if( mem.iMaster ){
+      memsys3Link(mem.iMaster);
+      mem.iMaster = 0;
+      mem.szMaster = 0;
+    }
+    for(i=0; i<N_HASH; i++){
+      memsys3Merge(&mem.aiHash[i]);
+    }
+    for(i=0; i<MX_SMALL-1; i++){
+      memsys3Merge(&mem.aiSmall[i]);
+    }
+    if( mem.szMaster ){
+      memsys3Unlink(mem.iMaster);
+      if( mem.szMaster>=nBlock ){
+        return memsys3FromMaster(nBlock);
+      }
     }
   }
 
index 258beacc925aa6a544f9f6c1b9f5f4725748067e..a7dc964c1fbff56571a25c9c05f4e55e736db239 100644 (file)
@@ -202,6 +202,7 @@ foreach file {
 
    mem1.c
    mem2.c
+   mem3.c
    mutex.c
    mutex_os2.c
    mutex_unix.c