diff options
author | David Corrales | 2007-08-05 19:34:20 +0000 |
---|---|---|
committer | David Corrales | 2007-08-05 19:34:20 +0000 |
commit | 6856535010bd2fa4449bcfde1c88dc06cd46e26f (patch) | |
tree | b81a2234c2beff0312c93e039d6cafda4babeca6 /engines/agos/items.cpp | |
parent | 1400d28bfb37fc94f3c44dec0a4d0cef65fb8fb7 (diff) | |
parent | ec1803f838d5efc7decf75c05a1fb4a9633751e5 (diff) | |
download | scummvm-rg350-6856535010bd2fa4449bcfde1c88dc06cd46e26f.tar.gz scummvm-rg350-6856535010bd2fa4449bcfde1c88dc06cd46e26f.tar.bz2 scummvm-rg350-6856535010bd2fa4449bcfde1c88dc06cd46e26f.zip |
Merged fsnode with trunk: r27971:28460
svn-id: r28462
Diffstat (limited to 'engines/agos/items.cpp')
-rw-r--r-- | engines/agos/items.cpp | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/engines/agos/items.cpp b/engines/agos/items.cpp index 9a46b6e8ac..b2e722d681 100644 --- a/engines/agos/items.cpp +++ b/engines/agos/items.cpp @@ -42,24 +42,15 @@ Child *AGOSEngine::allocateChildBlock(Item *i, uint type, uint size) { } byte *AGOSEngine::allocateItem(uint size) { - byte *org = _itemHeapPtr; - size = (size + sizeof(void*) - 1) & ~(sizeof(void*) - 1); + byte *item = new byte[size]; - _itemHeapPtr += size; - _itemHeapCurPos += size; - - if (_itemHeapCurPos > _itemHeapSize) - error("allocateItem: Itemheap overflow"); - - return org; + memset(item, 0, size); + _itemHeap.push_back(item); + return item; } void AGOSEngine::allocItemHeap() { - _itemHeapSize = _itemMemSize; - _itemHeapCurPos = 0; - _itemHeapPtr = (byte *)calloc(_itemMemSize, 1); - if (!_itemHeapPtr) - error("Out Of Memory - Items"); + _itemHeap.clear(); } bool AGOSEngine::hasIcon(Item *item) { @@ -391,8 +382,13 @@ int AGOSEngine::wordMatch(Item *item, int16 a, int16 n) { } Item *AGOSEngine::derefItem(uint item) { - if (item >= _itemArraySize) - error("derefItem: invalid item %d", item); + // Occurs when loading item store from restart state in + // Elvira 2 (Amiga/AtariST) and Waxworks (Amiga). + if (item >= _itemArraySize) { + debug(0, "derefItem: invalid item %d", item); + return NULL; + } + return _itemArrayPtr[item]; } |