arcm:: fixed the possible crash on deleting arcms with large cells, because of the confusion of cdata

This commit is contained in:
Zeno Rogue 2021-07-04 11:00:38 +02:00
parent f873a4ba18
commit e37fa65247
4 changed files with 6 additions and 14 deletions

View File

@ -694,12 +694,6 @@ struct hrmap_arbi : hrmap {
}
~hrmap_arbi() {
/*
if(hyperbolic) for(auto& p: arbi_matrix) if(p.second.first->cdata) {
delete p.second.first->cdata;
p.second.first->cdata = NULL;
}
*/
clearfrom(origin);
altmap.clear();
arbi_matrix.clear();

View File

@ -585,10 +585,6 @@ struct hrmap_archimedean : hrmap {
}
~hrmap_archimedean() {
if(hyperbolic) for(auto& p: archimedean_gmatrix) if(p.second.first->cdata) {
delete p.second.first->cdata;
p.second.first->cdata = NULL;
}
clearfrom(origin);
altmap.clear();
archimedean_gmatrix.clear();

View File

@ -378,9 +378,9 @@ EX void clearfrom(heptagon *at) {
q.pop();
DEBB(DF_MEMORY, ("from %p", at));
if(!at->c7) {
heptagon *h = (heptagon*) at->cdata;
heptagon *h = dynamic_cast<heptagon*> ((cdata_or_heptagon*) at->cdata);
if(h) {
if(h->alt != at) { DEBB(DF_MEMORY | DF_ERROR, ("alt error :: h->alt = ", h->alt)); }
if(h->alt != at) { DEBB(DF_MEMORY | DF_ERROR, ("alt error :: h->alt = ", h->alt, " expected ", at)); }
cell *c = h->c7;
subcell(c, destroycellcontents);
h->alt = NULL;

View File

@ -287,7 +287,9 @@ enum hstate { hsOrigin, hsA, hsB, hsError, hsA0, hsA1, hsB0, hsB1, hsC };
struct cell *createMov(struct cell *c, int d);
struct heptagon *createStep(struct heptagon *c, int d);
struct cdata {
struct cdata_or_heptagon { virtual ~cdata_or_heptagon() {} };
struct cdata : cdata_or_heptagon {
int val[4];
int bits;
};
@ -313,7 +315,7 @@ constexpr int iteration_limit = 10000000;
* heptagons are unused
*/
struct heptagon {
struct heptagon : cdata_or_heptagon {
/** \brief Automata are used to generate the standard maps. s is the state of this automaton */
hstate s : 6;
/** \brief distance modulo 4, in heptagons */