BLADERUNNER: Avoid using alloca, which might not be available on all systems.

This commit is contained in:
Kirben 2016-11-12 20:09:18 +11:00
parent 6ab6fb8b19
commit ef99a71d2a

View File

@ -34,8 +34,6 @@
#include "common/util.h"
#include "common/memstream.h"
namespace BladeRunner {
#define kAESC 0x41455343
@ -488,7 +486,7 @@ bool VQADecoder::readLNIN(Common::SeekableReadStream *s, uint32 size) {
if (chd.id != kLNIO || chd.size != 4u * loopNamesCount)
return false;
uint32 *loopNameOffsets = (uint32*)alloca(loopNamesCount * sizeof(uint32));
uint32 *loopNameOffsets = (uint32*)malloc(loopNamesCount * sizeof(uint32));
for (int i = 0; i != loopNamesCount; ++i) {
loopNameOffsets[i] = s->readUint32LE();
}
@ -497,7 +495,7 @@ bool VQADecoder::readLNIN(Common::SeekableReadStream *s, uint32 size) {
if (chd.id != kLNID)
return false;
char *names = (char*)alloca(roundup(chd.size));
char *names = (char*)malloc(roundup(chd.size));
s->read(names, roundup(chd.size));
for (int i = 0; i != loopNamesCount; ++i) {
@ -509,6 +507,8 @@ bool VQADecoder::readLNIN(Common::SeekableReadStream *s, uint32 size) {
// debug("%2d: %s", i, _loopInfo.loops[i].name.c_str());
}
free(loopNameOffsets);
free(names);
return true;
}