MCPcopy Create free account
hub / github.com/audacity/audacity / dbdataLoadPage

Function dbdataLoadPage

lib-src/sqlite/shell.c:10663–10696  ·  view source on GitHub ↗

** Load page pgno from the database via the sqlite_dbpage virtual table. ** If successful, set (*ppPage) to point to a buffer containing the page ** data, (*pnPage) to the size of that buffer in bytes and return ** SQLITE_OK. In this case it is the responsibility of the caller to ** eventually free the buffer using sqlite3_free(). ** ** Or, if an error occurs, set both (*ppPage) and (*pnPage) to 0

Source from the content-addressed store, hash-verified

10661** return an SQLite error code.
10662*/
10663static int dbdataLoadPage(
10664 DbdataCursor *pCsr, /* Cursor object */
10665 unsigned int pgno, /* Page number of page to load */
10666 u8 **ppPage, /* OUT: pointer to page buffer */
10667 int *pnPage /* OUT: Size of (*ppPage) in bytes */
10668){
10669 int rc2;
10670 int rc = SQLITE_OK;
10671 sqlite3_stmt *pStmt = pCsr->pStmt;
10672
10673 *ppPage = 0;
10674 *pnPage = 0;
10675 sqlite3_bind_int64(pStmt, 2, pgno);
10676 if( SQLITE_ROW==sqlite3_step(pStmt) ){
10677 int nCopy = sqlite3_column_bytes(pStmt, 0);
10678 if( nCopy>0 ){
10679 u8 *pPage;
10680 pPage = (u8*)sqlite3_malloc64(nCopy + DBDATA_PADDING_BYTES);
10681 if( pPage==0 ){
10682 rc = SQLITE_NOMEM;
10683 }else{
10684 const u8 *pCopy = sqlite3_column_blob(pStmt, 0);
10685 memcpy(pPage, pCopy, nCopy);
10686 memset(&pPage[nCopy], 0, DBDATA_PADDING_BYTES);
10687 }
10688 *ppPage = pPage;
10689 *pnPage = nCopy;
10690 }
10691 }
10692 rc2 = sqlite3_reset(pStmt);
10693 if( rc==SQLITE_OK ) rc = rc2;
10694
10695 return rc;
10696}
10697
10698/*
10699** Read a varint. Put the value in *pVal and return the number of bytes.

Callers 1

dbdataNextFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected