| OLD | NEW |
| 1 /* | 1 /* |
| 2 ** 2007 August 14 | 2 ** 2007 August 14 |
| 3 ** | 3 ** |
| 4 ** The author disclaims copyright to this source code. In place of | 4 ** The author disclaims copyright to this source code. In place of |
| 5 ** a legal notice, here is a blessing: | 5 ** a legal notice, here is a blessing: |
| 6 ** | 6 ** |
| 7 ** May you do good and not evil. | 7 ** May you do good and not evil. |
| 8 ** May you find forgiveness for yourself and forgive others. | 8 ** May you find forgiveness for yourself and forgive others. |
| 9 ** May you share freely, never taking more than you give. | 9 ** May you share freely, never taking more than you give. |
| 10 ** | 10 ** |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 ** Also used by Apple systems if SQLITE_WITHOUT_ZONEMALLOC is defined. | 72 ** Also used by Apple systems if SQLITE_WITHOUT_ZONEMALLOC is defined. |
| 73 */ | 73 */ |
| 74 #define SQLITE_MALLOC(x) malloc(x) | 74 #define SQLITE_MALLOC(x) malloc(x) |
| 75 #define SQLITE_FREE(x) free(x) | 75 #define SQLITE_FREE(x) free(x) |
| 76 #define SQLITE_REALLOC(x,y) realloc((x),(y)) | 76 #define SQLITE_REALLOC(x,y) realloc((x),(y)) |
| 77 | 77 |
| 78 /* | 78 /* |
| 79 ** The malloc.h header file is needed for malloc_usable_size() function | 79 ** The malloc.h header file is needed for malloc_usable_size() function |
| 80 ** on some systems (e.g. Linux). | 80 ** on some systems (e.g. Linux). |
| 81 */ | 81 */ |
| 82 #if defined(HAVE_MALLOC_H) && defined(HAVE_MALLOC_USABLE_SIZE) | 82 #if HAVE_MALLOC_H && HAVE_MALLOC_USABLE_SIZE |
| 83 # define SQLITE_USE_MALLOC_H | 83 # define SQLITE_USE_MALLOC_H 1 |
| 84 # define SQLITE_USE_MALLOC_USABLE_SIZE | 84 # define SQLITE_USE_MALLOC_USABLE_SIZE 1 |
| 85 /* | 85 /* |
| 86 ** The MSVCRT has malloc_usable_size(), but it is called _msize(). The | 86 ** The MSVCRT has malloc_usable_size(), but it is called _msize(). The |
| 87 ** use of _msize() is automatic, but can be disabled by compiling with | 87 ** use of _msize() is automatic, but can be disabled by compiling with |
| 88 ** -DSQLITE_WITHOUT_MSIZE. Using the _msize() function also requires | 88 ** -DSQLITE_WITHOUT_MSIZE. Using the _msize() function also requires |
| 89 ** the malloc.h header file. | 89 ** the malloc.h header file. |
| 90 */ | 90 */ |
| 91 #elif defined(_MSC_VER) && !defined(SQLITE_WITHOUT_MSIZE) | 91 #elif defined(_MSC_VER) && !defined(SQLITE_WITHOUT_MSIZE) |
| 92 # define SQLITE_USE_MALLOC_H | 92 # define SQLITE_USE_MALLOC_H |
| 93 # define SQLITE_USE_MSIZE | 93 # define SQLITE_USE_MSIZE |
| 94 #endif | 94 #endif |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 SQLITE_FREE(p); | 165 SQLITE_FREE(p); |
| 166 #endif | 166 #endif |
| 167 } | 167 } |
| 168 | 168 |
| 169 /* | 169 /* |
| 170 ** Report the allocated size of a prior return from xMalloc() | 170 ** Report the allocated size of a prior return from xMalloc() |
| 171 ** or xRealloc(). | 171 ** or xRealloc(). |
| 172 */ | 172 */ |
| 173 static int sqlite3MemSize(void *pPrior){ | 173 static int sqlite3MemSize(void *pPrior){ |
| 174 #ifdef SQLITE_MALLOCSIZE | 174 #ifdef SQLITE_MALLOCSIZE |
| 175 return pPrior ? (int)SQLITE_MALLOCSIZE(pPrior) : 0; | 175 assert( pPrior!=0 ); |
| 176 return (int)SQLITE_MALLOCSIZE(pPrior); |
| 176 #else | 177 #else |
| 177 sqlite3_int64 *p; | 178 sqlite3_int64 *p; |
| 178 if( pPrior==0 ) return 0; | 179 assert( pPrior!=0 ); |
| 179 p = (sqlite3_int64*)pPrior; | 180 p = (sqlite3_int64*)pPrior; |
| 180 p--; | 181 p--; |
| 181 return (int)p[0]; | 182 return (int)p[0]; |
| 182 #endif | 183 #endif |
| 183 } | 184 } |
| 184 | 185 |
| 185 /* | 186 /* |
| 186 ** Like realloc(). Resize an allocation previously obtained from | 187 ** Like realloc(). Resize an allocation previously obtained from |
| 187 ** sqlite3MemMalloc(). | 188 ** sqlite3MemMalloc(). |
| 188 ** | 189 ** |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 sqlite3MemSize, | 287 sqlite3MemSize, |
| 287 sqlite3MemRoundup, | 288 sqlite3MemRoundup, |
| 288 sqlite3MemInit, | 289 sqlite3MemInit, |
| 289 sqlite3MemShutdown, | 290 sqlite3MemShutdown, |
| 290 0 | 291 0 |
| 291 }; | 292 }; |
| 292 sqlite3_config(SQLITE_CONFIG_MALLOC, &defaultMethods); | 293 sqlite3_config(SQLITE_CONFIG_MALLOC, &defaultMethods); |
| 293 } | 294 } |
| 294 | 295 |
| 295 #endif /* SQLITE_SYSTEM_MALLOC */ | 296 #endif /* SQLITE_SYSTEM_MALLOC */ |
| OLD | NEW |