Do not allocate if no adjacencies.

This commit is contained in:
Guilhem Lavaux 2017-10-11 09:33:18 +02:00
parent 54aa135ac6
commit bbbb8e279e

View file

@ -88,10 +88,15 @@ void buildZoneAdjacencies(PARTICLE *p, pid_t np,
try try
{ {
for (int h = 0; h < numZones; h++) { for (int h = 0; h < numZones; h++) {
zt[h].adj = new pid_t[zt[h].nadj]; if (zt[h].nadj > 0) {
zt[h].slv = new float[zt[h].nadj]; zt[h].adj = new pid_t[zt[h].nadj];
nadjAlloced += zt[h].nadj; zt[h].slv = new float[zt[h].nadj];
zt[h].nadj = 0; nadjAlloced += zt[h].nadj;
zt[h].nadj = 0;
} else {
zt[h].adj = 0;
zt[h].slv = 0;
}
} }
} }
catch(const std::bad_alloc& a) catch(const std::bad_alloc& a)