From 46523e4d5d063cc7fffd59f8b6af3940fd685d93 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Wed, 11 Apr 2018 00:16:33 +0200 Subject: [PATCH] gp:: garbage collection --- cell.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/cell.cpp b/cell.cpp index 20ffbe7a..fcee86ac 100644 --- a/cell.cpp +++ b/cell.cpp @@ -858,17 +858,23 @@ void clearcell(cell *c) { heptagon deletion_marker; +template void subcell(cell *c, const T& t) { + if(gp::on) { + forCellEx(c2, c) if(c2->mov[0] == c && c2 != c2->master->c7) { + subcell(c2, t); + } + } + else if(!nonbitrunc) + forCellEx(c2, c) t(c2); + t(c); + } + void clearHexes(heptagon *at) { if(at->c7 && at->cdata) { delete at->cdata; at->cdata = NULL; } - if(at->c7) { - if(!nonbitrunc) for(int i=0; ic7->mov[i]); - } - clearcell(at->c7); - } + if(at->c7) subcell(at->c7, clearcell); } void unlink_cdata(heptagon *h) { @@ -894,8 +900,7 @@ void clearfrom(heptagon *at) { if(h) { if(h->alt != at) printf("alt error :: h->alt = %p\n", h->alt); cell *c = h->c7; - destroycellcontents(c); - forCellEx(c2, c) destroycellcontents(c2); + subcell(c, destroycellcontents); h->alt = NULL; at->cdata = NULL; }