-C Detect\scircularly\sdefined\sviews\sand\sissue\san\serror\smessage.\s\sTicket\s#1658.\s(CVS\s3055)
-D 2006-02-05T18:55:20
+C Update\sthe\sper-thread\sbytes\sallocated\scounter\swith\sthe\snumber\sof\sbytes\sactually\sallocated,\snot\sthe\snumber\srequested.\sTicket\s#1660.\s(CVS\s3056)
+D 2006-02-06T13:59:43
F Makefile.in 5d8dff443383918b700e495de42ec65bc1c8865b
F Makefile.linux-gcc 74ba0eadf88748a9ce3fd03d2a3ede2e6715baec
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
F src/trigger.c 4d3644cbd16959b568c95ae73493402be8021b08
F src/update.c 14be4ba2f438919b4217085c02feff569e6cf1f2
F src/utf.c 1199766bbb0157931a83aa6eede6b6381177be64
-F src/util.c 82ee598519b8193184bdeab06b51a4ffa05ad60b
+F src/util.c 36ce845aa173c7347251e7462d61f937b78c88fb
F src/vacuum.c 3865673cc66acd0717ecd517f6b8fdb2a5e7924b
F src/vdbe.c 29c68f39ce8cba44814b0e1f3d909ef961eb28a7
F src/vdbe.h 8729a4ee16ff9aeab2af9667df3cf300ff978e13
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P 3a04fc45ccc31f2009be812a9c9057844cf4ae3b
-R 968f57515475ab9a4a37d0ebf71134f3
-U drh
-Z a1def34602e0d016ada75d168beb6d52
+P f5341529d0cdbd63ce4c33606858158b6093969a
+R 74794a57a00f0992fd89f2fde95755fd
+U danielk1977
+Z eb9ce12217e4d8db003d2eaae05f7ed8
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
-** $Id: util.c,v 1.182 2006/01/23 15:39:59 drh Exp $
+** $Id: util.c,v 1.183 2006/02/06 13:59:43 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#define TESTALLOC_USERSIZE 64
const char *sqlite3_malloc_id = 0;
+/*
+** Always allocate blocks to be a multiple of the following size in bytes.
+** For example, if TESTALLOC_QUANTA is 8 and a block of 21 bytes is
+** requested, return a pointer to a block of 24 bytes.
+*/
+#define TESTALLOC_QUANTA 8
+
/*
** Blocks used by the test layer have the following format:
**
Tcl_Obj *pRes = Tcl_NewObj();
Tcl_IncrRefCount(pRes);
-
for(p=sqlite3_pFirst; p; p=((void **)p)[1]){
Tcl_Obj *pEntry = Tcl_NewObj();
Tcl_Obj *pStack = Tcl_NewObj();
MAX(sqlite3_nMaxAlloc, sqlite3ThreadDataReadOnly()->nAlloc);
#endif
assert( !sqlite3_mallocDisallowed );
+ n += (TESTALLOC_QUANTA - (n % TESTALLOC_QUANTA)) % TESTALLOC_QUANTA;
if( !sqlite3TestMallocFail() ){
u32 *p;
p = (u32 *)sqlite3OsMalloc(n + TESTALLOC_OVERHEAD);
sqlite3_nMaxAlloc =
MAX(sqlite3_nMaxAlloc, sqlite3ThreadDataReadOnly()->nAlloc);
#endif
+ n += (TESTALLOC_QUANTA - (n % TESTALLOC_QUANTA)) % TESTALLOC_QUANTA;
assert( !sqlite3_mallocDisallowed );
if( !sqlite3TestMallocFail() ){
- u32 *p = (u32 *)getOsPointer(pRealloc);
- checkGuards(p);
+ u32 *p = 0;
+ if( pRealloc ){
+ u32 *p = (u32 *)getOsPointer(pRealloc);
+ checkGuards(p);
+ }
p = sqlite3OsRealloc(p, n + TESTALLOC_OVERHEAD);
applyGuards(p);
relinkAlloc(p);
*/
void *sqlite3MallocRaw(int n){
void *p = 0;
- if( n>0 && !sqlite3MallocFailed() && !handleSoftLimit(n) ){
+ if( n>0 && !sqlite3MallocFailed() ){
while( (p = OSMALLOC(n))==0 && sqlite3_release_memory(n) );
- if( !p ){
- /* If the allocation failed, call handleSoftLimit() again, this time
- ** with the additive inverse of the argument passed to
- ** handleSoftLimit() above. This is so the ThreadData.nAlloc variable is
- ** still correct after a malloc() failure.
- */
- (void)handleSoftLimit(n * -1);
+ if( !p || handleSoftLimit(OSSIZEOF(p)) ){
+ OSFREE(p);
sqlite3FailedMalloc();
OSMALLOC_FAILED();
}
** attempt to free memory by calling sqlite3_release_memory().
*/
void *sqlite3Realloc(void *p, int n){
- if( sqlite3MallocFailed() ){
- return 0;
- }
-
- if( !p ){
- return sqlite3Malloc(n);
- }else{
- void *np = 0;
- if( !handleSoftLimit(n - OSSIZEOF(p)) ){
- while( (np = OSREALLOC(p, n))==0 && sqlite3_release_memory(n) );
- if( !np ){
- /* If the allocation failed, call handleSoftLimit() again, this time
- ** with the additive inverse of the argument passed to
- ** handleSoftLimit() above. This is so the ThreadData.nAlloc variable is
- ** still correct after a malloc() failure.
- */
- (void)handleSoftLimit(OSSIZEOF(p) - n);
- sqlite3FailedMalloc();
- OSMALLOC_FAILED();
- }
+ void *np = 0;
+ if( !sqlite3MallocFailed() ){
+#ifndef SQLITE_ENABLE_MEMORY_MANAGEMENT
+ int oldsize = OSSIZEOF(p);
+#endif
+ while( (np = OSREALLOC(p, n))==0 && sqlite3_release_memory(n) );
+ if( !np || handleSoftLimit(OSSIZEOF(np) - oldsize) ){
+ OSFREE(np);
+ sqlite3FailedMalloc();
+ OSMALLOC_FAILED();
}
- return np;
}
+ return np;
}
/*