From 149d48fb9e3e8147cf0bce84a4e11164ac9cdbf3 Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Thu, 30 Jan 2014 00:11:46 -0500 Subject: Fix leaf/branch deserialization. --- db.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'db.go') diff --git a/db.go b/db.go index a29b517..578a134 100644 --- a/db.go +++ b/db.go @@ -158,19 +158,19 @@ func (db *DB) init() error { m.version = Version m.pageSize = uint32(db.pageSize) m.version = Version - m.free = 3 - m.sys.root = 4 + m.free = 2 + m.sys.root = 3 } // Write an empty freelist at page 3. p := db.pageInBuffer(buf[:], pgid(2)) - p.id = pgid(3) + p.id = pgid(2) p.flags = p_freelist p.count = 0 // Write an empty leaf page at page 4. p = db.pageInBuffer(buf[:], pgid(3)) - p.id = pgid(4) + p.id = pgid(3) p.flags = p_leaf p.count = 0 @@ -226,7 +226,10 @@ func (db *DB) RWTransaction() (*RWTransaction, error) { } // Create a transaction associated with the database. - t := &RWTransaction{} + t := &RWTransaction{ + branches: make(map[pgid]*branch), + leafs: make(map[pgid]*leaf), + } t.init(db, db.meta()) return t, nil -- cgit v1.2.3