aboutsummaryrefslogtreecommitdiff
path: root/src/os_unix.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/os_unix.c')
-rw-r--r--src/os_unix.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index 35d29ad3c..5257bfd5e 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -1739,6 +1739,19 @@ int sqlite3_tsd_count = 0;
# define TSD_COUNTER(N) /* no-op */
#endif
+#if 0 && defined(SQLITE_MEMDEBUG)
+static void *mallocThreadData(size_t nBytes){
+ if( sqlite3_iMallocFail>=0 ){
+ sqlite3_iMallocFail--;
+ if( sqlite3_iMallocFail==0 ){
+ return 0;
+ }
+ }
+ return sqlite3OsMalloc(nBytes);
+}
+#else
+ #define mallocThreadData(x) sqlite3OsMalloc(x)
+#endif
/*
** If called with allocateFlag>0, then return a pointer to thread
@@ -1778,7 +1791,7 @@ ThreadData *sqlite3UnixThreadSpecificData(int allocateFlag){
pTsd = pthread_getspecific(key);
if( allocateFlag>0 ){
if( pTsd==0 ){
- pTsd = sqlite3OsMalloc(sizeof(zeroData));
+ pTsd = mallocThreadData(sizeof(zeroData));
if( pTsd ){
*pTsd = zeroData;
pthread_setspecific(key, pTsd);
@@ -1797,7 +1810,7 @@ ThreadData *sqlite3UnixThreadSpecificData(int allocateFlag){
static ThreadData *pTsd = 0;
if( allocateFlag>0 ){
if( pTsd==0 ){
- pTsd = sqlite3OsMalloc( sizeof(zeroData) );
+ pTsd = mallocThreadData( sizeof(zeroData) );
if( pTsd ){
*pTsd = zeroData;
TSD_COUNTER(+1);