/ Check-in [e9b55ccc]
Login

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

Overview
Comment:Remove the actual checks that verify that memory pools (such as set up using SQLITE_CONFIG_HEAP) are 8-byte aligned. But document that 8-byte alignment is required. (CVS 6742)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e9b55ccc8b6d4f21c9c8f8e7ba053475833fc833
User & Date: drh 2009-06-09 19:53:58
Context
2009-06-10
09:11
Minor tweak to balance_quick() to save a few instructions. (CVS 6743) check-in: 9ace9959 user: danielk1977 tags: trunk
2009-06-09
19:53
Remove the actual checks that verify that memory pools (such as set up using SQLITE_CONFIG_HEAP) are 8-byte aligned. But document that 8-byte alignment is required. (CVS 6742) check-in: e9b55ccc user: drh tags: trunk
18:58
Fix compiler warnings with MSVC build. (CVS 6741) check-in: 0bd84e73 user: shane tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/main.c.

    10     10   **
    11     11   *************************************************************************
    12     12   ** Main file for the SQLite library.  The routines in this file
    13     13   ** implement the programmer interface to the library.  Routines in
    14     14   ** other files are for internal use by SQLite and should not be
    15     15   ** accessed by users of the library.
    16     16   **
    17         -** $Id: main.c,v 1.556 2009/06/09 18:02:10 drh Exp $
           17  +** $Id: main.c,v 1.557 2009/06/09 19:53:58 drh Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   
    21     21   #ifdef SQLITE_ENABLE_FTS3
    22     22   # include "fts3.h"
    23     23   #endif
    24     24   #ifdef SQLITE_ENABLE_RTREE
................................................................................
   334    334   #if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5)
   335    335       case SQLITE_CONFIG_HEAP: {
   336    336         /* Designate a buffer for heap memory space */
   337    337         sqlite3GlobalConfig.pHeap = va_arg(ap, void*);
   338    338         sqlite3GlobalConfig.nHeap = va_arg(ap, int);
   339    339         sqlite3GlobalConfig.mnReq = va_arg(ap, int);
   340    340   
   341         -      /* Must have 8-byte alignment */
   342         -      if( ((sqlite3GlobalConfig.pHeap - (char*)0)&7)!=0 ){
   343         -        return SQLITE_MISUSE;
   344         -      }
   345         -
   346    341         if( sqlite3GlobalConfig.pHeap==0 ){
   347    342           /* If the heap pointer is NULL, then restore the malloc implementation
   348    343           ** back to NULL pointers too.  This will cause the malloc to go
   349    344           ** back to its default implementation when sqlite3_initialize() is
   350    345           ** run.
   351    346           */
   352    347           memset(&sqlite3GlobalConfig.m, 0, sizeof(sqlite3GlobalConfig.m));

Changes to src/sqlite.h.in.

    26     26   ** on how SQLite interfaces are suppose to operate.
    27     27   **
    28     28   ** The name of this file under configuration management is "sqlite.h.in".
    29     29   ** The makefile makes some minor changes to this file (such as inserting
    30     30   ** the version number) and changes its name to "sqlite3.h" as
    31     31   ** part of the build process.
    32     32   **
    33         -** @(#) $Id: sqlite.h.in,v 1.456 2009/06/09 18:02:10 drh Exp $
           33  +** @(#) $Id: sqlite.h.in,v 1.457 2009/06/09 19:53:58 drh Exp $
    34     34   */
    35     35   #ifndef _SQLITE3_H_
    36     36   #define _SQLITE3_H_
    37     37   #include <stdarg.h>     /* Needed for the definition of va_list */
    38     38   
    39     39   /*
    40     40   ** Make sure we can call this stuff from C++.
................................................................................
  1032   1032   **   <li> [sqlite3_soft_heap_limit()]
  1033   1033   **   <li> [sqlite3_status()]
  1034   1034   **   </ul>
  1035   1035   ** </dd>
  1036   1036   **
  1037   1037   ** <dt>SQLITE_CONFIG_SCRATCH</dt>
  1038   1038   ** <dd>This option specifies a static memory buffer that SQLite can use for
  1039         -** scratch memory.  There are three arguments:  A pointer to the memory, the
  1040         -** size of each scratch buffer (sz), and the number of buffers (N).  The sz
         1039  +** scratch memory.  There are three arguments:  A pointer an 8-byte
         1040  +** aligned memory buffer from which the scrach allocations will be
         1041  +** drawn, the size of each scratch allocation (sz),
         1042  +** and the maximum number of scratch allocations (N).  The sz
  1041   1043   ** argument must be a multiple of 16. The sz parameter should be a few bytes
  1042         -** larger than the actual scratch space required due internal overhead.
  1043         -** The first
  1044         -** argument should point to an allocation of at least sz*N bytes of memory.
         1044  +** larger than the actual scratch space required due to internal overhead.
         1045  +** The first argument should pointer to an 8-byte aligned buffer
         1046  +** of at least sz*N bytes of memory.
  1045   1047   ** SQLite will use no more than one scratch buffer at once per thread, so
  1046   1048   ** N should be set to the expected maximum number of threads.  The sz
  1047   1049   ** parameter should be 6 times the size of the largest database page size.
  1048   1050   ** Scratch buffers are used as part of the btree balance operation.  If
  1049   1051   ** The btree balancer needs additional memory beyond what is provided by
  1050   1052   ** scratch buffers or if no scratch buffer space is specified, then SQLite
  1051   1053   ** goes to [sqlite3_malloc()] to obtain the memory it needs.</dd>
  1052   1054   **
  1053   1055   ** <dt>SQLITE_CONFIG_PAGECACHE</dt>
  1054   1056   ** <dd>This option specifies a static memory buffer that SQLite can use for
  1055   1057   ** the database page cache with the default page cache implemenation.  
  1056   1058   ** This configuration should not be used if an application-define page
  1057   1059   ** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option.
  1058         -** There are three arguments to this option: A pointer to the
         1060  +** There are three arguments to this option: A pointer to 8-byte aligned
  1059   1061   ** memory, the size of each page buffer (sz), and the number of pages (N).
  1060         -** The sz argument must be a power of two between 512 and 32768.  The first
         1062  +** The sz argument should be the size of the largest database page
         1063  +** (a power of two between 512 and 32768) plus a little extra for each
         1064  +** page header.  The page header size is 20 to 40 bytes depending on
         1065  +** the host architecture.  It is harmless, apart from the wasted memory,
         1066  +** to make sz a little too large.  The first
  1061   1067   ** argument should point to an allocation of at least sz*N bytes of memory.
  1062   1068   ** SQLite will use the memory provided by the first argument to satisfy its
  1063   1069   ** memory needs for the first N pages that it adds to cache.  If additional
  1064   1070   ** page cache memory is needed beyond what is provided by this option, then
  1065   1071   ** SQLite goes to [sqlite3_malloc()] for the additional storage space.
  1066   1072   ** The implementation might use one or more of the N buffers to hold 
  1067         -** memory accounting information. </dd>
         1073  +** memory accounting information. The pointer in the first argument must
         1074  +** be aligned to an 8-byte boundary or subsequent behavior of SQLite
         1075  +** will be undefined.</dd>
  1068   1076   **
  1069   1077   ** <dt>SQLITE_CONFIG_HEAP</dt>
  1070   1078   ** <dd>This option specifies a static memory buffer that SQLite will use
  1071   1079   ** for all of its dynamic memory allocation needs beyond those provided
  1072   1080   ** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE].
  1073         -** There are three arguments: A pointer to the memory, the number of
  1074         -** bytes in the memory buffer, and the minimum allocation size.  If
  1075         -** the first pointer (the memory pointer) is NULL, then SQLite reverts
         1081  +** There are three arguments: An 8-byte aligned pointer to the memory,
         1082  +** the number of bytes in the memory buffer, and the minimum allocation size.
         1083  +** If the first pointer (the memory pointer) is NULL, then SQLite reverts
  1076   1084   ** to using its default memory allocator (the system malloc() implementation),
  1077   1085   ** undoing any prior invocation of [SQLITE_CONFIG_MALLOC].  If the
  1078   1086   ** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or
  1079   1087   ** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory
  1080   1088   ** allocator is engaged to handle all of SQLites memory allocation needs.
  1081   1089   ** The first pointer (the memory pointer) must be aligned to an 8-byte
  1082         -** boundary or the behavior is undefined.</dd>
         1090  +** boundary or subsequent behavior of SQLite will be undefined.</dd>
  1083   1091   **
  1084   1092   ** <dt>SQLITE_CONFIG_MUTEX</dt>
  1085   1093   ** <dd>This option takes a single argument which is a pointer to an
  1086   1094   ** instance of the [sqlite3_mutex_methods] structure.  The argument specifies
  1087   1095   ** alternative low-level mutex routines to be used in place
  1088   1096   ** the mutex routines built into SQLite.</dd>
  1089   1097   **
................................................................................
  1146   1154   ** is invoked.
  1147   1155   **
  1148   1156   ** <dl>
  1149   1157   ** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
  1150   1158   ** <dd>This option takes three additional arguments that determine the 
  1151   1159   ** [lookaside memory allocator] configuration for the [database connection].
  1152   1160   ** The first argument (the third parameter to [sqlite3_db_config()] is a
  1153         -** pointer to a memory buffer to use for lookaside memory.  The first
  1154         -** argument may be NULL in which case SQLite will allocate the lookaside
  1155         -** buffer itself using [sqlite3_malloc()].  The second argument is the
         1161  +** pointer to an 8-byte aligned memory buffer to use for lookaside memory.
         1162  +** The first argument may be NULL in which case SQLite will allocate the
         1163  +** lookaside buffer itself using [sqlite3_malloc()].  The second argument is the
  1156   1164   ** size of each lookaside buffer slot and the third argument is the number of
  1157   1165   ** slots.  The size of the buffer in the first argument must be greater than
  1158   1166   ** or equal to the product of the second and third arguments.</dd>
  1159   1167   **
  1160   1168   ** </dl>
  1161   1169   */
  1162   1170   #define SQLITE_DBCONFIG_LOOKASIDE    1001  /* void* int int */