Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add the SQLITE_WITHOUT_MSIZE and SQLITE_WITHOUT_ZONEMALLOC macros in mem1.c to disable the use of _msize() on windows and the zone memory allocator on Apple products, respectively. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
238e35a4411a5b2231576254dba39b80 |
User & Date: | drh 2012-01-18 12:46:47 |
Context
2012-01-18
| ||
18:22 | Avoid overriding the malloc_usable_size symbol using the C preprocessor as this might be confusing the build on some systems. (check-in: bbaec351 user: drh tags: trunk) | |
12:46 | Add the SQLITE_WITHOUT_MSIZE and SQLITE_WITHOUT_ZONEMALLOC macros in mem1.c to disable the use of _msize() on windows and the zone memory allocator on Apple products, respectively. (check-in: 238e35a4 user: drh tags: trunk) | |
01:14 | Remove a redundant assignment from the VM. (check-in: d0dabe2f user: drh tags: trunk) | |
Changes
Changes to src/mem1.c.
︙ | ︙ | |||
11 12 13 14 15 16 17 | ************************************************************************* ** ** This file contains low-level memory allocation drivers for when ** SQLite will use the standard C-library malloc/realloc/free interface ** to obtain the memory it needs. ** ** This file contains implementations of the low-level memory allocation | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > | > | | > | > | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | ************************************************************************* ** ** This file contains low-level memory allocation drivers for when ** SQLite will use the standard C-library malloc/realloc/free interface ** to obtain the memory it needs. ** ** This file contains implementations of the low-level memory allocation ** routines specified in the sqlite3_mem_methods object. The content of ** this file is only used if SQLITE_SYSTEM_MALLOC is defined. The ** SQLITE_SYSTEM_MALLOC macro is defined automatically if neither the ** SQLITE_MEMDEBUG nor the SQLITE_WIN32_MALLOC macros are defined. The ** default configuration is to use memory allocation routines in this ** file. ** ** C-preprocessor macro summary: ** ** HAVE_MALLOC_USABLE_SIZE The configure script sets this symbol if ** the malloc_usable_size() interface exists ** on the target platform. Or, this symbol ** can be set manually, if desired. ** If an equivalent interface exists by ** a different name, using a separate -D ** option to rename it. This symbol will ** be enabled automatically on windows ** systems, and malloc_usable_size() will ** be redefined to _msize(), unless the ** SQLITE_WITHOUT_MSIZE macro is defined. ** ** SQLITE_WITHOUT_ZONEMALLOC Some older macs lack support for the zone ** memory allocator. Set this symbol to enable ** building on older macs. ** ** SQLITE_WITHOUT_MSIZE Set this symbol to disable the use of ** _msize() on windows systems. This might ** be necessary when compiling for Delphi, ** for example. */ #include "sqliteInt.h" /* ** This version of the memory allocator is the default. It is ** used when no other memory allocator is specified using compile-time ** macros. */ #ifdef SQLITE_SYSTEM_MALLOC /* ** Windows systems have malloc_usable_size() but it is called _msize(). ** The use of _msize() is automatic, but can be disabled by compiling ** with -DSQLITE_WITHOUT_MSIZE */ #if !defined(HAVE_MALLOC_USABLE_SIZE) && SQLITE_OS_WIN \ && !defined(SQLITE_WITHOUT_MSIZE) # define HAVE_MALLOC_USABLE_SIZE 1 # define malloc_usable_size _msize #endif #if defined(__APPLE__) && !defined(SQLITE_WITHOUT_ZONEMALLOC) /* ** Use the zone allocator available on apple products unless the ** SQLITE_WITHOUT_ZONEMALLOC symbol is defined. */ #include <sys/sysctl.h> #include <malloc/malloc.h> #include <libkern/OSAtomic.h> static malloc_zone_t* _sqliteZone_; #define SQLITE_MALLOC(x) malloc_zone_malloc(_sqliteZone_, (x)) #define SQLITE_FREE(x) malloc_zone_free(_sqliteZone_, (x)); #define SQLITE_REALLOC(x,y) malloc_zone_realloc(_sqliteZone_, (x), (y)) #define SQLITE_MALLOCSIZE(x) \ (_sqliteZone_ ? _sqliteZone_->size(_sqliteZone_,x) : malloc_size(x)) #else /* if not __APPLE__ */ /* ** Use standard C library malloc and free on non-Apple systems. ** Also used by Apple systems if SQLITE_WITHOUT_ZONEMALLOC is defined. */ #define SQLITE_MALLOC(x) malloc(x) #define SQLITE_FREE(x) free(x) #define SQLITE_REALLOC(x,y) realloc((x),(y)) #ifdef HAVE_MALLOC_USABLE_SIZE #include <malloc.h> |
︙ | ︙ | |||
180 181 182 183 184 185 186 | return ROUND8(n); } /* ** Initialize this module. */ static int sqlite3MemInit(void *NotUsed){ | | | 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | return ROUND8(n); } /* ** Initialize this module. */ static int sqlite3MemInit(void *NotUsed){ #if defined(__APPLE__) && !defined(SQLITE_WITHOUT_ZONEMALLOC) int cpuCount; size_t len; if( _sqliteZone_ ){ return SQLITE_OK; } len = sizeof(cpuCount); /* One usually wants to use hw.acctivecpu for MT decisions, but not here */ |
︙ | ︙ |