diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-03-29 14:28:53 -0600 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-03-29 14:28:53 -0600 |
commit | fcce87626ceeb4e9477b915f89aa0e9e3add5860 (patch) | |
tree | d8381077fb0d78b86219491d5331589cf470042a /node.go | |
parent | Merge pull request #97 from benbjohnson/cli (diff) | |
parent | Add DB.Check(). (diff) | |
download | dedo-fcce87626ceeb4e9477b915f89aa0e9e3add5860.tar.gz dedo-fcce87626ceeb4e9477b915f89aa0e9e3add5860.tar.xz |
Merge pull request #98 from benbjohnson/fsck
Add DB.Check().
Diffstat (limited to 'node.go')
-rw-r--r-- | node.go | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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 |