Skip to content

Commit

Permalink
use heap alloc for temp playfields to try to alleviate memory access …
Browse files Browse the repository at this point in the history
…issues on OS X
  • Loading branch information
devinacker committed Jun 2, 2015
1 parent 951f85f commit f53db02
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ QList<QByteArray*> saveLevel(leveldata_t *level, int *fieldSize) {
chunks.append(new QByteArray((const char*)packed, packedSize));

// step 6: create packed playfield tilemaps and write them
uint16_t playfield[2][MAX_FIELD_HEIGHT][MAX_FIELD_WIDTH];
auto playfield = new uint16_t[2][MAX_FIELD_HEIGHT][MAX_FIELD_WIDTH];

makeIsometricMap(playfield, level);

uint16_t rowStarts [CHUNK_SIZE / 2] = {0};
Expand Down Expand Up @@ -287,6 +288,8 @@ QList<QByteArray*> saveLevel(leveldata_t *level, int *fieldSize) {
index += rowLen;
}

delete[] playfield;

if (fieldSize) {
*fieldSize = index * 2;
}
Expand Down

0 comments on commit f53db02

Please sign in to comment.