Avoid unnecessary calls to the xRoundup() method of the memory allocator when
the soft heap limit is not set. FossilOrigin-Name: 4209b89eab01814228a178963238e0dffffad2a4
This commit is contained in:
parent
d9bcb32ebb
commit
1d21bac8aa
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C Fix\sa\spotential\sassertion\sfault\sdiscovered\sby\sOSS-Fuzz.
|
||||
D 2017-01-10T15:08:06.289
|
||||
C Avoid\sunnecessary\scalls\sto\sthe\sxRoundup()\smethod\sof\sthe\smemory\sallocator\swhen\nthe\ssoft\sheap\slimit\sis\snot\sset.
|
||||
D 2017-01-10T16:09:46.718
|
||||
F Makefile.in 41bd4cad981487345c4a84081074bcdb876e4b2e
|
||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||
F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da
|
||||
@ -354,7 +354,7 @@ F src/insert.c 7761fd63136771d411f096f4d7a1af9c5057ddd4
|
||||
F src/legacy.c 75d3023be8f0d2b99d60f905090341a03358c58e
|
||||
F src/loadext.c 5d6642d141c07d366e43d359e94ec9de47add41d
|
||||
F src/main.c e207b81542d13b9f13d61e78ca441f9781f055b0
|
||||
F src/malloc.c f3fad34cd570022abca558c573f1761fb09a8212
|
||||
F src/malloc.c c36ef8fa6e4cc53ec258c5aa3ad86eb47350cc3d
|
||||
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
|
||||
F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b
|
||||
F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3
|
||||
@ -1543,7 +1543,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P a5fa09657bd6c4ea5fe6712b0f8af2170cbe0381
|
||||
R 9d11b71201b21d28f9619103dd00f618
|
||||
P 71c03b59b645884ebd6b9e18713cd2eb8c949870
|
||||
R 631021f153b5b713372ffbd6126c74cb
|
||||
U drh
|
||||
Z 82e96cf4e2e496f2e42165b862cbc10e
|
||||
Z 02d94bfa17296c03c0e8153386f8771f
|
||||
|
@ -1 +1 @@
|
||||
71c03b59b645884ebd6b9e18713cd2eb8c949870
|
||||
4209b89eab01814228a178963238e0dffffad2a4
|
12
src/malloc.c
12
src/malloc.c
@ -217,14 +217,13 @@ static void sqlite3MallocAlarm(int nByte){
|
||||
** Do a memory allocation with statistics and alarms. Assume the
|
||||
** lock is already held.
|
||||
*/
|
||||
static int mallocWithAlarm(int n, void **pp){
|
||||
int nFull;
|
||||
static void mallocWithAlarm(int n, void **pp){
|
||||
void *p;
|
||||
assert( sqlite3_mutex_held(mem0.mutex) );
|
||||
nFull = sqlite3GlobalConfig.m.xRoundup(n);
|
||||
sqlite3StatusHighwater(SQLITE_STATUS_MALLOC_SIZE, n);
|
||||
if( mem0.alarmThreshold>0 ){
|
||||
sqlite3_int64 nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);
|
||||
int nFull = sqlite3GlobalConfig.m.xRoundup(n);
|
||||
if( nUsed >= mem0.alarmThreshold - nFull ){
|
||||
mem0.nearlyFull = 1;
|
||||
sqlite3MallocAlarm(nFull);
|
||||
@ -232,20 +231,19 @@ static int mallocWithAlarm(int n, void **pp){
|
||||
mem0.nearlyFull = 0;
|
||||
}
|
||||
}
|
||||
p = sqlite3GlobalConfig.m.xMalloc(nFull);
|
||||
p = sqlite3GlobalConfig.m.xMalloc(n);
|
||||
#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
|
||||
if( p==0 && mem0.alarmThreshold>0 ){
|
||||
sqlite3MallocAlarm(nFull);
|
||||
p = sqlite3GlobalConfig.m.xMalloc(nFull);
|
||||
p = sqlite3GlobalConfig.m.xMalloc(n);
|
||||
}
|
||||
#endif
|
||||
if( p ){
|
||||
nFull = sqlite3MallocSize(p);
|
||||
int nFull = sqlite3MallocSize(p);
|
||||
sqlite3StatusUp(SQLITE_STATUS_MEMORY_USED, nFull);
|
||||
sqlite3StatusUp(SQLITE_STATUS_MALLOC_COUNT, 1);
|
||||
}
|
||||
*pp = p;
|
||||
return nFull;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user