MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / recoverInit

Function recoverInit

modules/dasSQLITE/sqlite/shell.c:16155–16187  ·  view source on GitHub ↗

** This is a worker function that does the heavy lifting for both init ** functions: ** ** sqlite3_recover_init() ** sqlite3_recover_init_sql() ** ** All this function does is allocate space for the recover handle and ** take copies of the input parameters. All the real work is done within ** sqlite3_recover_run(). */

Source from the content-addressed store, hash-verified

16153** sqlite3_recover_run().
16154*/
16155sqlite3_recover *recoverInit(
16156 sqlite3* db,
16157 const char *zDb,
16158 const char *zUri, /* Output URI for _recover_init() */
16159 int (*xSql)(void*, const char*),/* SQL callback for _recover_init_sql() */
16160 void *pSqlCtx /* Context arg for _recover_init_sql() */
16161){
16162 sqlite3_recover *pRet = 0;
16163 int nDb = 0;
16164 int nUri = 0;
16165 int nByte = 0;
16166
16167 if( zDb==0 ){ zDb = "main"; }
16168
16169 nDb = recoverStrlen(zDb);
16170 nUri = recoverStrlen(zUri);
16171
16172 nByte = sizeof(sqlite3_recover) + nDb+1 + nUri+1;
16173 pRet = (sqlite3_recover*)sqlite3_malloc(nByte);
16174 if( pRet ){
16175 memset(pRet, 0, nByte);
16176 pRet->dbIn = db;
16177 pRet->zDb = (char*)&pRet[1];
16178 pRet->zUri = &pRet->zDb[nDb+1];
16179 memcpy(pRet->zDb, zDb, nDb);
16180 if( nUri>0 && zUri ) memcpy(pRet->zUri, zUri, nUri);
16181 pRet->xSql = xSql;
16182 pRet->pSqlCtx = pSqlCtx;
16183 pRet->bRecoverRowid = RECOVER_ROWID_DEFAULT;
16184 }
16185
16186 return pRet;
16187}
16188
16189/*
16190** Initialize a recovery handle that creates a new database containing

Callers 2

sqlite3_recover_initFunction · 0.85
sqlite3_recover_init_sqlFunction · 0.85

Calls 1

recoverStrlenFunction · 0.85

Tested by

no test coverage detected