/* ** Set the soft heap-size limit for the current thread. Passing a negative ** value indicates no limit. */ void sqlite3_soft_heap_limit(int n){ ThreadData *pTd = sqlite3ThreadData(); if( pTd ){ pTd->nSoftHeapLimit = n; } sqlite3ReleaseThreadData(); }
static void updateMemoryUsedCount(int n){ ThreadData *pTsd = sqlite3ThreadData(); if( pTsd ){ pTsd->nAlloc += n; assert( pTsd->nAlloc>=0 ); if( pTsd->nAlloc==0 && pTsd->nSoftHeapLimit==0 ){ sqlite3ReleaseThreadData(); } } }
static int enforceSoftLimit(int n){ ThreadData *pTsd = sqlite3ThreadData(); if( pTsd==0 ){ return 0; } assert( pTsd->nAlloc>=0 ); if( n>0 && pTsd->nSoftHeapLimit>0 ){ while( pTsd->nAlloc+n>pTsd->nSoftHeapLimit && sqlite3_release_memory(n) ){} } return 1; }
/* ** Enable or disable the shared pager and schema features for the ** current thread. ** ** This routine should only be called when there are no open ** database connections. */ int sqlite3_enable_shared_cache(int enable){ ThreadData *pTd = sqlite3ThreadData(); if( pTd ){ /* It is only legal to call sqlite3_enable_shared_cache() when there ** are no currently open b-trees that were opened by the calling thread. ** This condition is only easy to detect if the shared-cache were ** previously enabled (and is being disabled). */ if( pTd->pBtree && !enable ){ assert( pTd->useSharedData ); return SQLITE_MISUSE; } pTd->useSharedData = enable; sqlite3ReleaseThreadData(); } return sqlite3ApiExit(0, SQLITE_OK); }