From b79eb4de1d6704736f2f03779bb86b29368b44b4 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Mon, 6 Apr 2020 09:26:59 +0200 Subject: [PATCH] fixed cellcount --- cell.cpp | 8 +++++++- locations.cpp | 3 +-- nonisotropic.cpp | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cell.cpp b/cell.cpp index 47d8fa5b..815f1cf1 100644 --- a/cell.cpp +++ b/cell.cpp @@ -138,12 +138,18 @@ EX int dirdiff(int dd, int t) { EX int cellcount = 0; +EX void destroy_cell(cell *c) { + tailored_delete(c); + cellcount--; + } + EX cell *newCell(int type, heptagon *master) { cell *c = tailored_alloc (type); c->type = type; c->master = master; initcell(c); hybrid::will_link(c); + cellcount++; return c; } @@ -327,7 +333,7 @@ EX void clearcell(cell *c) { c->move(t)->move(c->c.spin(t)) = NULL; } DEBB(DF_MEMORY, (format("DEL %p\n", hr::voidp(c)))); - tailored_delete(c); + destroy_cell(c); } EX heptagon deletion_marker; diff --git a/locations.cpp b/locations.cpp index ab1960e9..2dc5bd10 100644 --- a/locations.cpp +++ b/locations.cpp @@ -98,12 +98,11 @@ struct gcell { int cellid; #endif - gcell() { cellcount++; + gcell() { #ifdef CELLID cellid = cellcount; #endif } - ~gcell() { cellcount--; } }; #define landparam LHU.landpar diff --git a/nonisotropic.cpp b/nonisotropic.cpp index 1fe1daf9..3894fd16 100644 --- a/nonisotropic.cpp +++ b/nonisotropic.cpp @@ -1147,7 +1147,7 @@ EX namespace hybrid { ~hrmap_hybrid() { in_underlying([] { delete currentmap; }); - for(auto& p: at) tailored_delete(p.second); + for(auto& p: at) destroy_cell(p.second); } virtual transmatrix spin_to(cell *c, int d, ld bonus) override { if(d >= c->type-2) return Id; c = get_where(c).first; return in_underlying([&] { return currentmap->spin_to(c, d, bonus); }); }