int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag){ sqlite3_int64 iCur, iHwtr; int rc; #ifdef SQLITE_ENABLE_API_ARMOR if( pCurrent==0 || pHighwater==0 ) return SQLITE_MISUSE_BKPT; #endif rc = sqlite3_status64(op, &iCur, &iHwtr, resetFlag); if( rc==0 ){ *pCurrent = (int)iCur; *pHighwater = (int)iHwtr; } return rc; }
/* ** Advance a memstat_cursor to its next row of output. */ static int memstatNext(sqlite3_vtab_cursor *cur){ memstat_cursor *pCur = (memstat_cursor*)cur; int i; assert( pCur->iRowid<=MSV_NROW ); while(1){ i = (int)pCur->iRowid - 1; if( i<0 || (aMemstatColumn[i].mNull & 2)!=0 || (++pCur->iDb)>=pCur->nDb ){ pCur->iRowid++; if( pCur->iRowid>MSV_NROW ) return SQLITE_OK; /* End of the table */ pCur->iDb = 0; i++; } pCur->aVal[0] = 0; pCur->aVal[1] = 0; switch( aMemstatColumn[i].eType ){ case MSV_GSTAT: { if( sqlite3_libversion_number()>=3010000 ){ sqlite3_status64(aMemstatColumn[i].eOp, &pCur->aVal[0], &pCur->aVal[1],0); }else{ int xCur, xHiwtr; sqlite3_status(aMemstatColumn[i].eOp, &xCur, &xHiwtr, 0); pCur->aVal[0] = xCur; pCur->aVal[1] = xHiwtr; } break; } case MSV_DB: { int xCur, xHiwtr; sqlite3_db_status(pCur->db, aMemstatColumn[i].eOp, &xCur, &xHiwtr, 0); pCur->aVal[0] = xCur; pCur->aVal[1] = xHiwtr; break; } case MSV_ZIPVFS: { int rc; rc = sqlite3_file_control(pCur->db, pCur->azDb[pCur->iDb], aMemstatColumn[i].eOp, (void*)&pCur->aVal[0]); if( rc!=SQLITE_OK ) continue; break; } } break; } return SQLITE_OK; }
/* ** Return the maximum amount of memory that has ever been ** checked out since either the beginning of this process ** or since the most recent reset. */ sqlite3_int64 sqlite3_memory_highwater(int resetFlag){ sqlite3_int64 res, mx; sqlite3_status64(SQLITE_STATUS_MEMORY_USED, &res, &mx, resetFlag); return mx; }
/* ** Return the amount of memory currently checked out. */ sqlite3_int64 sqlite3_memory_used(void){ sqlite3_int64 res, mx; sqlite3_status64(SQLITE_STATUS_MEMORY_USED, &res, &mx, 0); return res; }