/ Check-in [aca2bee8]
Login

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

Overview
Comment:Fix some VdbeMemCopy() related problems. (CVS 4787)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: aca2bee8662c3adaa47b3e70b1ef35347111f9eb
User & Date: danielk1977 2008-02-14 15:31:52
Context
2008-02-14
23:24
Fix a typo in a comment used to generate documentation. (CVS 4788) check-in: 65e66dd8 user: drh tags: trunk
15:31
Fix some VdbeMemCopy() related problems. (CVS 4787) check-in: aca2bee8 user: danielk1977 tags: trunk
05:44
Fix a problem in the ptrchng.test script. (CVS 4786) check-in: 30a45f07 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to src/mem3.c.

    16     16   ** use of malloc().  All dynamically allocatable memory is
    17     17   ** contained in a static array, mem.aPool[].  The size of this
    18     18   ** fixed memory pool is SQLITE_MEMORY_SIZE bytes.
    19     19   **
    20     20   ** This version of the memory allocation subsystem is used if
    21     21   ** and only if SQLITE_MEMORY_SIZE is defined.
    22     22   **
    23         -** $Id: mem3.c,v 1.9 2008/02/13 18:25:27 danielk1977 Exp $
           23  +** $Id: mem3.c,v 1.10 2008/02/14 15:31:52 danielk1977 Exp $
    24     24   */
    25     25   
    26     26   /*
    27     27   ** This version of the memory allocator is used only when 
    28     28   ** SQLITE_MEMORY_SIZE is defined.
    29     29   */
    30     30   #if defined(SQLITE_MEMORY_SIZE)
................................................................................
   288    288   
   289    289   /*
   290    290   ** Return the size of an outstanding allocation, in bytes.  The
   291    291   ** size returned omits the 8-byte header overhead.  This only
   292    292   ** works for chunks that are currently checked out.
   293    293   */
   294    294   int sqlite3MallocSize(void *p){
          295  +  int iSize = 0;
          296  +  if( p ){
   295    297     Mem3Block *pBlock = (Mem3Block*)p;
   296    298     assert( (pBlock[-1].u.hdr.size4x&1)!=0 );
   297         -  return (pBlock[-1].u.hdr.size4x&~3)*2 - 4;
          299  +    iSize = (pBlock[-1].u.hdr.size4x&~3)*2 - 4;
          300  +  }
          301  +  return iSize;
   298    302   }
   299    303   
   300    304   /*
   301    305   ** Chunk i is a free chunk that has been unlinked.  Adjust its 
   302    306   ** size parameters for check-out and return a pointer to the 
   303    307   ** user portion of the chunk.
   304    308   */

Changes to src/vdbemem.c.

   536    536     int rc = SQLITE_OK;
   537    537     char *zBuf = 0;
   538    538   
   539    539     /* If cell pTo currently has a reusable buffer, save a pointer to it
   540    540     ** in local variable zBuf. This function attempts to avoid freeing
   541    541     ** this buffer.
   542    542     */
          543  +  if( pTo->flags&MEM_Dyn ){
   543    544     if( pTo->xDel ){
   544    545       sqlite3VdbeMemRelease(pTo);
   545         -  }else if( pTo->flags&MEM_Dyn ){
          546  +    }else{
   546    547       zBuf = pTo->z;
   547    548     }
          549  +  }
   548    550   
   549    551     /* Copy the contents of *pFrom to *pTo */
   550    552     memcpy(pTo, pFrom, sizeof(*pFrom));
   551    553   
   552    554     if( pTo->flags&(MEM_Str|MEM_Blob) && pTo->flags&MEM_Static ){
   553    555       /* pFrom contained a pointer to a static string. In this case,
   554    556       ** free any dynamically allocated buffer associated with pTo.