aboutsummaryrefslogtreecommitdiff
path: root/src/btree.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/btree.c')
-rw-r--r--src/btree.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/btree.c b/src/btree.c
index cbf93d222..c02f070e0 100644
--- a/src/btree.c
+++ b/src/btree.c
@@ -3278,8 +3278,8 @@ int sqlite3BtreeSavepoint(Btree *p, int op, int iSavepoint){
** root page of a b-tree. If it is not, then the cursor acquired
** will not work correctly.
**
-** It is assumed that the sqlite3BtreeCursorSize() bytes of memory
-** pointed to by pCur have been zeroed by the caller.
+** It is assumed that the sqlite3BtreeCursorZero() has been called
+** on pCur to initialize the memory space prior to invoking this routine.
*/
static int btreeCursor(
Btree *p, /* The btree */
@@ -3356,6 +3356,18 @@ int sqlite3BtreeCursorSize(void){
}
/*
+** Initialize memory that will be converted into a BtCursor object.
+**
+** The simple approach here would be to memset() the entire object
+** to zero. But it turns out that the apPage[] and aiIdx[] arrays
+** do not need to be zeroed and they are large, so we can save a lot
+** of run-time by skipping the initialization of those elements.
+*/
+void sqlite3BtreeCursorZero(BtCursor *p){
+ memset(p, 0, offsetof(BtCursor, iPage));
+}
+
+/*
** Set the cached rowid value of every cursor in the same database file
** as pCur and having the same root page number as pCur. The value is
** set to iRowid.