mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
packing: Improve panic messages
This commit is contained in:
parent
09dcba40ab
commit
c15348f939
@ -147,7 +147,7 @@ func (p *Page) Size() int {
|
|||||||
|
|
||||||
func (p *Page) Alloc(width, height int) *Node {
|
func (p *Page) Alloc(width, height int) *Node {
|
||||||
if width <= 0 || height <= 0 {
|
if width <= 0 || height <= 0 {
|
||||||
panic("bsp: width and height must > 0")
|
panic("packing: width and height must > 0")
|
||||||
}
|
}
|
||||||
if p.root == nil {
|
if p.root == nil {
|
||||||
p.root = &Node{
|
p.root = &Node{
|
||||||
@ -167,14 +167,14 @@ func (p *Page) Alloc(width, height int) *Node {
|
|||||||
|
|
||||||
func (p *Page) Free(node *Node) {
|
func (p *Page) Free(node *Node) {
|
||||||
if node.child0 != nil || node.child1 != nil {
|
if node.child0 != nil || node.child1 != nil {
|
||||||
panic("bsp: can't free the node including children")
|
panic("packing: can't free the node including children")
|
||||||
}
|
}
|
||||||
node.used = false
|
node.used = false
|
||||||
if node.parent == nil {
|
if node.parent == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if node.parent.child0 == nil || node.parent.child1 == nil {
|
if node.parent.child0 == nil || node.parent.child1 == nil {
|
||||||
panic("not reached")
|
panic("not reached: double free?")
|
||||||
}
|
}
|
||||||
if node.parent.child0.canFree() && node.parent.child1.canFree() {
|
if node.parent.child0.canFree() && node.parent.child1.canFree() {
|
||||||
node.parent.child0 = nil
|
node.parent.child0 = nil
|
||||||
|
Loading…
Reference in New Issue
Block a user