From 7f2de9f17a8c6113176ecb5a3eb6ecc0772a9ec1 Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Fri, 28 Mar 2014 00:07:05 -0600 Subject: Add DB.Check(). --- node.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'node.go') diff --git a/node.go b/node.go index 51be690..0a4c7af 100644 --- a/node.go +++ b/node.go @@ -258,6 +258,7 @@ func (n *node) rebalance() { // Remove old child. child.parent = nil delete(n.tx.nodes, child.pgid) + child.free() } return @@ -318,6 +319,7 @@ func (n *node) rebalance() { n.inodes = append(n.inodes, target.inodes...) n.parent.del(target.key) delete(n.tx.nodes, target.pgid) + target.free() } else { // Reparent all child nodes being moved. for _, inode := range n.inodes { @@ -331,6 +333,7 @@ func (n *node) rebalance() { n.parent.del(n.key) n.parent.put(target.key, target.inodes[0].key, nil, target.pgid) delete(n.tx.nodes, n.pgid) + n.free() } // Either this node or the target node was deleted from the parent so rebalance it. @@ -357,6 +360,13 @@ func (n *node) dereference() { } } +// free adds the node's underlying page to the freelist. +func (n *node) free() { + if n.pgid != 0 { + n.tx.db.freelist.free(n.tx.id(), n.tx.page(n.pgid)) + } +} + // nodesByDepth sorts a list of branches by deepest first. type nodesByDepth []*node -- cgit v1.2.3