/ Check-in [4209b89e]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Avoid unnecessary calls to the xRoundup() method of the memory allocator when the soft heap limit is not set.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4209b89eab01814228a178963238e0dffffad2a4
User & Date: drh 2017-01-10 16:09:46
Context
2017-01-10
17:33
Throw an error if the ON clause of a LEFT JOIN references tables to the right of the ON clause. Fix for ticket [25e335f802dd]. check-in: c92ecff2 user: drh tags: trunk
16:09
Avoid unnecessary calls to the xRoundup() method of the memory allocator when the soft heap limit is not set. check-in: 4209b89e user: drh tags: trunk
15:08
Fix a potential assertion fault discovered by OSS-Fuzz. check-in: 71c03b59 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/malloc.c.

   213    213     sqlite3_mutex_enter(mem0.mutex);
   214    214   }
   215    215   
   216    216   /*
   217    217   ** Do a memory allocation with statistics and alarms.  Assume the
   218    218   ** lock is already held.
   219    219   */
   220         -static int mallocWithAlarm(int n, void **pp){
   221         -  int nFull;
          220  +static void mallocWithAlarm(int n, void **pp){
   222    221     void *p;
   223    222     assert( sqlite3_mutex_held(mem0.mutex) );
   224         -  nFull = sqlite3GlobalConfig.m.xRoundup(n);
   225    223     sqlite3StatusHighwater(SQLITE_STATUS_MALLOC_SIZE, n);
   226    224     if( mem0.alarmThreshold>0 ){
   227    225       sqlite3_int64 nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);
          226  +    int nFull = sqlite3GlobalConfig.m.xRoundup(n);
   228    227       if( nUsed >= mem0.alarmThreshold - nFull ){
   229    228         mem0.nearlyFull = 1;
   230    229         sqlite3MallocAlarm(nFull);
   231    230       }else{
   232    231         mem0.nearlyFull = 0;
   233    232       }
   234    233     }
   235         -  p = sqlite3GlobalConfig.m.xMalloc(nFull);
          234  +  p = sqlite3GlobalConfig.m.xMalloc(n);
   236    235   #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
   237    236     if( p==0 && mem0.alarmThreshold>0 ){
   238    237       sqlite3MallocAlarm(nFull);
   239         -    p = sqlite3GlobalConfig.m.xMalloc(nFull);
          238  +    p = sqlite3GlobalConfig.m.xMalloc(n);
   240    239     }
   241    240   #endif
   242    241     if( p ){
   243         -    nFull = sqlite3MallocSize(p);
          242  +    int nFull = sqlite3MallocSize(p);
   244    243       sqlite3StatusUp(SQLITE_STATUS_MEMORY_USED, nFull);
   245    244       sqlite3StatusUp(SQLITE_STATUS_MALLOC_COUNT, 1);
   246    245     }
   247    246     *pp = p;
   248         -  return nFull;
   249    247   }
   250    248   
   251    249   /*
   252    250   ** Allocate memory.  This routine is like sqlite3_malloc() except that it
   253    251   ** assumes the memory subsystem has already been initialized.
   254    252   */
   255    253   void *sqlite3Malloc(u64 n){