Bug fix in the realloc algorithm of the static memory allocator. (CVS 4497)

FossilOrigin-Name: 50db16be5025f6d5efc51e3354615059da7e8611
This commit is contained in:
drh 2007-10-20 16:11:39 +00:00
parent a4e5d58f02
commit c0ad3e8df6
3 changed files with 9 additions and 11 deletions

View File

@ -1,5 +1,5 @@
C Simplify\sthe\smem3.c\smemory\sallocator.\s\sHave\sit\scall\ssqlite3_release_memory()\nautomatically,\swithout\shaving\sto\sspecify\sthe\ssoft\sheap\slimit.\s(CVS\s4496)
D 2007-10-20T15:41:58
C Bug\sfix\sin\sthe\srealloc\salgorithm\sof\sthe\sstatic\smemory\sallocator.\s(CVS\s4497)
D 2007-10-20T16:11:39
F Makefile.in 30c7e3ba426ddb253b8ef037d1873425da6009a8
F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@ -104,7 +104,7 @@ F src/malloc.c de4e77fe70a9a0ac47a1c3a874422b107231bf31
F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217
F src/mem1.c cacb202bc379da10d69aa66d497c0ea7bd9cd8a5
F src/mem2.c 3f669b5e20975a5a2ca392aca891cd686e22b097
F src/mem3.c 0a86f5a93f8adf8604c0f346e2e99d7f01494cae
F src/mem3.c 232f658b5919a979e894817e8d9a8047cc01738a
F src/mutex.c 3259f62c2429967aee6dc112117a6d2f499ef061
F src/mutex.h 079fa6fe9da18ceb89e79012c010594c6672addb
F src/mutex_os2.c 7fe4773e98ed74a63b2e54fc557929eb155f6269
@ -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 f56c9884be796dee3f267aca6021eb1846d8527c
R 99add766d4a1a5f07507dd355d51b89c
P ca51b2f54076fcf73a8857aecf4b45d66ef0c7b6
R 149041cc2a0cdac1aeaffd2ccb597c27
U drh
Z 2b02a1a666d477f557917b5280cb451c
Z c7cecaa706d7ed7726d405d4a3f2983e

View File

@ -1 +1 @@
ca51b2f54076fcf73a8857aecf4b45d66ef0c7b6
50db16be5025f6d5efc51e3354615059da7e8611

View 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.3 2007/10/20 15:41:58 drh Exp $
** $Id: mem3.c,v 1.4 2007/10/20 16:11:39 drh Exp $
*/
/*
@ -274,7 +274,7 @@ static void memsys3OutOfMemory(int nByte){
static int memsys3Size(void *p){
Mem3Block *pBlock = (Mem3Block*)p;
assert( pBlock[-1].u.hdr.size<0 );
return (1-pBlock[-1].u.hdr.size)*8;
return (-1-pBlock[-1].u.hdr.size)*8;
}
/*
@ -517,11 +517,9 @@ void *sqlite3_realloc(void *pPrior, int nBytes){
}
assert( mem.mutex!=0 );
nOld = memsys3Size(pPrior);
#if 0
if( nBytes<=nOld && nBytes>=nOld-128 ){
return pPrior;
}
#endif
sqlite3_mutex_enter(mem.mutex);
p = memsys3Malloc(nBytes);
if( p ){