mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-02-02 12:19:18 +00:00
tailored_delete used for deleting cells and heptagons, so that there is no delete/delete[] mismatch
This commit is contained in:
parent
91873c19c6
commit
b0b783b581
18
cell.cpp
18
cell.cpp
@ -99,7 +99,7 @@ struct hrmap_spherical : hrmap {
|
|||||||
hrmap_spherical() {
|
hrmap_spherical() {
|
||||||
mvar = variation;
|
mvar = variation;
|
||||||
for(int i=0; i<spherecells(); i++) {
|
for(int i=0; i<spherecells(); i++) {
|
||||||
heptagon& h = *(dodecahedron[i] = new heptagon);
|
heptagon& h = *(dodecahedron[i] = tailored_alloc<heptagon> (S7));
|
||||||
h.s = hsOrigin;
|
h.s = hsOrigin;
|
||||||
h.emeraldval = i;
|
h.emeraldval = i;
|
||||||
h.zebraval = i;
|
h.zebraval = i;
|
||||||
@ -190,7 +190,7 @@ struct hrmap_spherical : hrmap {
|
|||||||
~hrmap_spherical() {
|
~hrmap_spherical() {
|
||||||
dynamicval<eVariation> ph(variation, mvar);
|
dynamicval<eVariation> ph(variation, mvar);
|
||||||
for(int i=0; i<spherecells(); i++) clearHexes(dodecahedron[i]);
|
for(int i=0; i<spherecells(); i++) clearHexes(dodecahedron[i]);
|
||||||
for(int i=0; i<spherecells(); i++) delete dodecahedron[i];
|
for(int i=0; i<spherecells(); i++) tailored_delete(dodecahedron[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void verify() {
|
void verify() {
|
||||||
@ -533,7 +533,7 @@ struct hrmap_torus : hrmap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
~hrmap_torus() {
|
~hrmap_torus() {
|
||||||
for(cell *c: all) delete c;
|
for(cell *c: all) tailored_delete(c);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -561,7 +561,7 @@ struct hrmap_euclidean : hrmap {
|
|||||||
}
|
}
|
||||||
~euclideanSlab() {
|
~euclideanSlab() {
|
||||||
for(int y=0; y<256; y++) for(int x=0; x<256; x++)
|
for(int y=0; y<256; y++) for(int x=0; x<256; x++)
|
||||||
if(a[y][x]) delete a[y][x];
|
if(a[y][x]) tailored_delete(a[y][x]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -590,7 +590,7 @@ struct hrmap_euclidean : hrmap {
|
|||||||
~hrmap_euclidean() {
|
~hrmap_euclidean() {
|
||||||
for(int y=0; y<slabs; y++) for(int x=0; x<slabs; x++)
|
for(int y=0; y<slabs; y++) for(int x=0; x<slabs; x++)
|
||||||
if(euclidean[y][x]) {
|
if(euclidean[y][x]) {
|
||||||
delete euclidean[y][x];
|
tailored_delete(euclidean[y][x]);
|
||||||
euclidean[y][x] = NULL;
|
euclidean[y][x] = NULL;
|
||||||
}
|
}
|
||||||
eucdata.clear();
|
eucdata.clear();
|
||||||
@ -969,7 +969,7 @@ struct hrmap_quotient : hrmap {
|
|||||||
// printf("all cells = %d\n", TOT*(S7+S3)/S3);
|
// printf("all cells = %d\n", TOT*(S7+S3)/S3);
|
||||||
if(!TOT) exit(1);
|
if(!TOT) exit(1);
|
||||||
allh.resize(TOT);
|
allh.resize(TOT);
|
||||||
for(int i=0; i<TOT; i++) allh[i] = new heptagon;
|
for(int i=0; i<TOT; i++) allh[i] = tailored_alloc<heptagon> (S7);
|
||||||
// heptagon *oldorigin = origin;
|
// heptagon *oldorigin = origin;
|
||||||
allh[0]->alt = base.origin;
|
allh[0]->alt = base.origin;
|
||||||
|
|
||||||
@ -1030,7 +1030,7 @@ struct hrmap_quotient : hrmap {
|
|||||||
~hrmap_quotient() {
|
~hrmap_quotient() {
|
||||||
for(int i=0; i<isize(allh); i++) {
|
for(int i=0; i<isize(allh); i++) {
|
||||||
clearHexes(allh[i]);
|
clearHexes(allh[i]);
|
||||||
delete allh[i];
|
tailored_delete(allh[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1203,7 +1203,7 @@ void clearcell(cell *c) {
|
|||||||
c->move(t)->move(c->c.spin(t)) = NULL;
|
c->move(t)->move(c->c.spin(t)) = NULL;
|
||||||
}
|
}
|
||||||
DEBMEM ( printf("DEL %p\n", c); )
|
DEBMEM ( printf("DEL %p\n", c); )
|
||||||
delete c;
|
tailored_delete(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
heptagon deletion_marker;
|
heptagon deletion_marker;
|
||||||
@ -1273,7 +1273,7 @@ void clearfrom(heptagon *at) {
|
|||||||
at->move(i) = NULL;
|
at->move(i) = NULL;
|
||||||
}
|
}
|
||||||
clearHexes(at);
|
clearHexes(at);
|
||||||
delete at;
|
tailored_delete(at);
|
||||||
}
|
}
|
||||||
//printf("maxq = %d\n", maxq);
|
//printf("maxq = %d\n", maxq);
|
||||||
}
|
}
|
||||||
|
4
hyper.h
4
hyper.h
@ -432,6 +432,10 @@ template<class T> T* tailored_alloc(int degree) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void inline tailored_delete(void *x) {
|
||||||
|
delete[] ((char*) (x));
|
||||||
|
}
|
||||||
|
|
||||||
static const struct wstep_t { wstep_t() {} } wstep;
|
static const struct wstep_t { wstep_t() {} } wstep;
|
||||||
static const struct wmirror_t { wmirror_t() {}} wmirror;
|
static const struct wmirror_t { wmirror_t() {}} wmirror;
|
||||||
static const struct rev_t { rev_t() {} } rev;
|
static const struct rev_t { rev_t() {} } rev;
|
||||||
|
Loading…
Reference in New Issue
Block a user