SQLite

Check-in [8651aba186]
Login

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

Overview
Comment:Clear a valgrind error by zeroing the first 4 bytes of the temp-space allocation used by the b-tree module.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 8651aba1865a8f82d21d3345f33fbd239fd9a042
User & Date: dan 2013-10-16 11:39:07.819
Context
2013-10-16
23:58
Fix a typo in a requirements mark comment. No changes to code. (check-in: e5a439cfa5 user: drh tags: trunk)
14:32
Merge the latest trunk changes. (check-in: 5806546822 user: drh tags: sessions)
11:39
Clear a valgrind error by zeroing the first 4 bytes of the temp-space allocation used by the b-tree module. (check-in: 8651aba186 user: dan tags: trunk)
11:31
Fix memory and resource leaks for WinCE and Cygwin, and a compiler warning on windows with SQLITE_THREADSAFE=0. (check-in: 9905cea9d4 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/btree.c.
2048
2049
2050
2051
2052
2053
2054












2055
2056
2057
2058
2059
2060
2061
/*
** Make sure pBt->pTmpSpace points to an allocation of 
** MX_CELL_SIZE(pBt) bytes.
*/
static void allocateTempSpace(BtShared *pBt){
  if( !pBt->pTmpSpace ){
    pBt->pTmpSpace = sqlite3PageMalloc( pBt->pageSize );












  }
}

/*
** Free the pBt->pTmpSpace allocation
*/
static void freeTempSpace(BtShared *pBt){







>
>
>
>
>
>
>
>
>
>
>
>







2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
/*
** Make sure pBt->pTmpSpace points to an allocation of 
** MX_CELL_SIZE(pBt) bytes.
*/
static void allocateTempSpace(BtShared *pBt){
  if( !pBt->pTmpSpace ){
    pBt->pTmpSpace = sqlite3PageMalloc( pBt->pageSize );

    /* One of the uses of pBt->pTmpSpace is to format cells before
    ** inserting them into a leaf page (function fillInCell()). If
    ** a cell is less than 4 bytes in size, it is rounded up to 4 bytes
    ** by the various routines that manipulate binary cells. Which
    ** can mean that fillInCell() only initializes the first 2 or 3
    ** bytes of pTmpSpace, but that the first 4 bytes are copied from
    ** it into a database page. This is not actually a problem, but it
    ** does cause a valgrind error when the 1 or 2 bytes of unitialized 
    ** data is passed to system call write(). So to avoid this error,
    ** zero the first 4 bytes of temp space here.  */
    if( pBt->pTmpSpace ) memset(pBt->pTmpSpace, 0, 4);
  }
}

/*
** Free the pBt->pTmpSpace allocation
*/
static void freeTempSpace(BtShared *pBt){