diff options
author | danielk1977 <danielk1977@noemail.net> | 2006-01-17 16:10:13 +0000 |
---|---|---|
committer | danielk1977 <danielk1977@noemail.net> | 2006-01-17 16:10:13 +0000 |
commit | cbb8496c5e8ce0b46bb4e09ec2a2994aa62c7d2c (patch) | |
tree | 507db4bbabc5327a8666a5ce12fcb4696447a268 /src | |
parent | 08659fee65062a45324c627ec122cf4b7c70d0b9 (diff) | |
download | sqlite-cbb8496c5e8ce0b46bb4e09ec2a2994aa62c7d2c.tar.gz sqlite-cbb8496c5e8ce0b46bb4e09ec2a2994aa62c7d2c.zip |
Arrange for ThreadData to be automatically deallocated even if SQLITE_MEMDEBUG is defined. Fix for #1623. (CVS 2965)
FossilOrigin-Name: 9e2e40845d30cc150abe23ee318a721b4fe9613c
Diffstat (limited to 'src')
-rw-r--r-- | src/os_unix.c | 4 | ||||
-rw-r--r-- | src/os_win.c | 2 | ||||
-rw-r--r-- | src/sqliteInt.h | 20 |
3 files changed, 21 insertions, 5 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index 12152befe..9263744b3 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -1769,7 +1769,7 @@ ThreadData *sqlite3UnixThreadSpecificData(int allocateFlag){ } } }else if( pTsd!=0 && allocateFlag<0 - && memcmp(pTsd, &zeroData, sizeof(zeroData))==0 ){ + && memcmp(pTsd, &zeroData, THREADDATASIZE)==0 ){ sqlite3OsFree(pTsd); pthread_setspecific(key, 0); TSD_COUNTER(-1); @@ -1787,7 +1787,7 @@ ThreadData *sqlite3UnixThreadSpecificData(int allocateFlag){ } } }else if( pTsd!=0 && allocateFlag<0 - && memcmp(pTsd, &zeroData, sizeof(zeroData))==0 ){ + && memcmp(pTsd, &zeroData, THREADDATASIZE)==0 ){ sqlite3OsFree(pTsd); TSD_COUNTER(-1); pTsd = 0; diff --git a/src/os_win.c b/src/os_win.c index d8a495c67..e184c3018 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -1207,7 +1207,7 @@ ThreadData *sqlite3WinThreadSpecificData(int allocateFlag){ } } }else if( pTsd!=0 && allocateFlag<0 - && memcmp(pTsd, &zeroData, sizeof(zeroData))==0 ){ + && memcmp(pTsd, &zeroData, THREADDATASIZE)==0 ){ sqlite3OsFree(pTsd); TlsSetValue(key, 0); TSD_COUNTER_DECR; diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 8865f4eb9..2c8ea0844 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -11,7 +11,7 @@ ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.471 2006/01/17 15:36:32 danielk1977 Exp $ +** @(#) $Id: sqliteInt.h,v 1.472 2006/01/17 16:10:14 danielk1977 Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ @@ -310,16 +310,32 @@ struct ThreadData { #endif #ifdef SQLITE_MEMDEBUG + void *pFirst; /* Pointer to linked list of allocations */ int nMaxAlloc; /* High water mark of ThreadData.nAlloc */ int mallocDisallowed; /* assert() in sqlite3Malloc() if set */ int isFail; /* True if all malloc() calls should fail */ const char *zFile; /* Filename to associate debugging info with */ int iLine; /* Line number to associate debugging info with */ - void *pFirst; /* Pointer to linked list of allocations */ #endif }; /* +** The THREADDATASIZE macro is used by the system that automatically +** deallocates ThreadData structures. If the first THREADDATASIZE bytes +** of a ThreadData structure are all zero, then the structure is eligible +** for deallocation. +** +** Usually, THREADDATASIZE is set to the size of the structure. However +** if SQLITE_MEMDEBUG is defined, all variables declared after the +** ThreadData.pFirst variable are excluded. +*/ +#ifdef SQLITE_MEMDEBUG + #define THREADDATASIZE (int)(&(((ThreadData *)0)->nMaxAlloc)) +#else + #define THREADDATASIZE sizeof(ThreadData) +#endif + +/* ** Name of the master database table. The master database table ** is a special table that holds the names and attributes of all ** user tables and indices. |