| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 /* | 118 /* |
| 119 ** Like malloc(), but remember the size of the allocation | 119 ** Like malloc(), but remember the size of the allocation |
| 120 ** so that we can find it later using sqlite3MemSize(). | 120 ** so that we can find it later using sqlite3MemSize(). |
| 121 ** | 121 ** |
| 122 ** For this low-level routine, we are guaranteed that nByte>0 because | 122 ** For this low-level routine, we are guaranteed that nByte>0 because |
| 123 ** cases of nByte<=0 will be intercepted and dealt with by higher level | 123 ** cases of nByte<=0 will be intercepted and dealt with by higher level |
| 124 ** routines. | 124 ** routines. |
| 125 */ | 125 */ |
| 126 static void *sqlite3MemMalloc(int nByte){ | 126 static void *sqlite3MemMalloc(int nByte){ |
| 127 #ifdef SQLITE_MALLOCSIZE | 127 #ifdef SQLITE_MALLOCSIZE |
| 128 void *p = SQLITE_MALLOC( nByte ); | 128 void *p; |
| 129 testcase( ROUND8(nByte)==nByte ); |
| 130 p = SQLITE_MALLOC( nByte ); |
| 129 if( p==0 ){ | 131 if( p==0 ){ |
| 130 testcase( sqlite3GlobalConfig.xLog!=0 ); | 132 testcase( sqlite3GlobalConfig.xLog!=0 ); |
| 131 sqlite3_log(SQLITE_NOMEM, "failed to allocate %u bytes of memory", nByte); | 133 sqlite3_log(SQLITE_NOMEM, "failed to allocate %u bytes of memory", nByte); |
| 132 } | 134 } |
| 133 return p; | 135 return p; |
| 134 #else | 136 #else |
| 135 sqlite3_int64 *p; | 137 sqlite3_int64 *p; |
| 136 assert( nByte>0 ); | 138 assert( nByte>0 ); |
| 137 nByte = ROUND8(nByte); | 139 testcase( ROUND8(nByte)!=nByte ); |
| 138 p = SQLITE_MALLOC( nByte+8 ); | 140 p = SQLITE_MALLOC( nByte+8 ); |
| 139 if( p ){ | 141 if( p ){ |
| 140 p[0] = nByte; | 142 p[0] = nByte; |
| 141 p++; | 143 p++; |
| 142 }else{ | 144 }else{ |
| 143 testcase( sqlite3GlobalConfig.xLog!=0 ); | 145 testcase( sqlite3GlobalConfig.xLog!=0 ); |
| 144 sqlite3_log(SQLITE_NOMEM, "failed to allocate %u bytes of memory", nByte); | 146 sqlite3_log(SQLITE_NOMEM, "failed to allocate %u bytes of memory", nByte); |
| 145 } | 147 } |
| 146 return (void *)p; | 148 return (void *)p; |
| 147 #endif | 149 #endif |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 sqlite3MemSize, | 289 sqlite3MemSize, |
| 288 sqlite3MemRoundup, | 290 sqlite3MemRoundup, |
| 289 sqlite3MemInit, | 291 sqlite3MemInit, |
| 290 sqlite3MemShutdown, | 292 sqlite3MemShutdown, |
| 291 0 | 293 0 |
| 292 }; | 294 }; |
| 293 sqlite3_config(SQLITE_CONFIG_MALLOC, &defaultMethods); | 295 sqlite3_config(SQLITE_CONFIG_MALLOC, &defaultMethods); |
| 294 } | 296 } |
| 295 | 297 |
| 296 #endif /* SQLITE_SYSTEM_MALLOC */ | 298 #endif /* SQLITE_SYSTEM_MALLOC */ |
| OLD | NEW |