Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Bug fix in the realloc algorithm of the static memory allocator. (CVS 4497) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
50db16be5025f6d5efc51e3354615059 |
User & Date: | drh 2007-10-20 16:11:39.000 |
Context
2007-10-20
| ||
16:36 | Add the new memory allocator to the amalgamation. Improvements to out-of-memory handling. (CVS 4498) (check-in: b58c2b37a5 user: drh tags: trunk) | |
16:11 | Bug fix in the realloc algorithm of the static memory allocator. (CVS 4497) (check-in: 50db16be50 user: drh tags: trunk) | |
15:41 | Simplify the mem3.c memory allocator. Have it call sqlite3_release_memory() automatically, without having to specify the soft heap limit. (CVS 4496) (check-in: ca51b2f540 user: drh tags: trunk) | |
Changes
Changes to src/mem3.c.
︙ | ︙ | |||
16 17 18 19 20 21 22 | ** use of malloc(). All dynamically allocatable memory is ** contained in a static array, mem.aPool[]. The size of this ** fixed memory pool is SQLITE_MEMORY_SIZE bytes. ** ** This version of the memory allocation subsystem is used if ** and only if SQLITE_MEMORY_SIZE is defined. ** | | | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | ** use of malloc(). All dynamically allocatable memory is ** contained in a static array, mem.aPool[]. The size of this ** fixed memory pool is SQLITE_MEMORY_SIZE bytes. ** ** 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 $ */ /* ** This version of the memory allocator is used only when ** SQLITE_MEMORY_SIZE is defined. */ #if defined(SQLITE_MEMORY_SIZE) |
︙ | ︙ | |||
270 271 272 273 274 275 276 | ** Return the size of an outstanding allocation, in bytes. The ** size returned omits the 8-byte header overhead. This only ** works for chunks that are currently checked out. */ static int memsys3Size(void *p){ Mem3Block *pBlock = (Mem3Block*)p; assert( pBlock[-1].u.hdr.size<0 ); | | | 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | ** Return the size of an outstanding allocation, in bytes. The ** size returned omits the 8-byte header overhead. This only ** works for chunks that are currently checked out. */ static int memsys3Size(void *p){ Mem3Block *pBlock = (Mem3Block*)p; assert( pBlock[-1].u.hdr.size<0 ); return (-1-pBlock[-1].u.hdr.size)*8; } /* ** Chunk i is a free chunk that has been unlinked. Adjust its ** size parameters for check-out and return a pointer to the ** user portion of the chunk. */ |
︙ | ︙ | |||
513 514 515 516 517 518 519 | } if( nBytes<=0 ){ sqlite3_free(pPrior); return 0; } assert( mem.mutex!=0 ); nOld = memsys3Size(pPrior); | < < | 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 | } if( nBytes<=0 ){ sqlite3_free(pPrior); return 0; } assert( mem.mutex!=0 ); nOld = memsys3Size(pPrior); if( nBytes<=nOld && nBytes>=nOld-128 ){ return pPrior; } sqlite3_mutex_enter(mem.mutex); p = memsys3Malloc(nBytes); if( p ){ if( nOld<nBytes ){ memcpy(p, pPrior, nOld); }else{ memcpy(p, pPrior, nBytes); |
︙ | ︙ |