diff options
author | Johannes Schickel | 2006-09-16 13:40:28 +0000 |
---|---|---|
committer | Johannes Schickel | 2006-09-16 13:40:28 +0000 |
commit | 84c2a93db511a06fb82894dee596a268ae5323db (patch) | |
tree | 4db429a271eaab221a0088a7f388bbb07292a649 | |
parent | b860f002b2f1f1a6cc67a9deb8360a8d421e2a4e (diff) | |
download | scummvm-rg350-84c2a93db511a06fb82894dee596a268ae5323db.tar.gz scummvm-rg350-84c2a93db511a06fb82894dee596a268ae5323db.tar.bz2 scummvm-rg350-84c2a93db511a06fb82894dee596a268ae5323db.zip |
Replaces all malloc/realloc usages with new.
svn-id: r23886
-rw-r--r-- | engines/kyra/kyra.cpp | 28 | ||||
-rw-r--r-- | engines/kyra/screen.cpp | 11 | ||||
-rw-r--r-- | engines/kyra/seqplayer.cpp | 6 | ||||
-rw-r--r-- | engines/kyra/sequences_v1.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/sprites.cpp | 13 |
5 files changed, 31 insertions, 29 deletions
diff --git a/engines/kyra/kyra.cpp b/engines/kyra/kyra.cpp index 9570e9f1be..2fb57d29c1 100644 --- a/engines/kyra/kyra.cpp +++ b/engines/kyra/kyra.cpp @@ -384,16 +384,16 @@ KyraEngine::~KyraEngine() { delete [] _movFacingTable; - free(_scrollUpButton.process0PtrShape); - free(_scrollUpButton.process1PtrShape); - free(_scrollUpButton.process2PtrShape); - free(_scrollDownButton.process0PtrShape); - free(_scrollDownButton.process1PtrShape); - free(_scrollDownButton.process2PtrShape); + delete [] _scrollUpButton.process0PtrShape; + delete [] _scrollUpButton.process1PtrShape; + delete [] _scrollUpButton.process2PtrShape; + delete [] _scrollDownButton.process0PtrShape; + delete [] _scrollDownButton.process1PtrShape; + delete [] _scrollDownButton.process2PtrShape; for (int i = 0; i < ARRAYSIZE(_shapes); ++i) { if (_shapes[i] != 0) { - free(_shapes[i]); + delete [] _shapes[i]; for (int i2 = 0; i2 < ARRAYSIZE(_shapes); i2++) { if (_shapes[i2] == _shapes[i] && i2 != i) { _shapes[i2] = 0; @@ -403,7 +403,7 @@ KyraEngine::~KyraEngine() { } } for (int i = 0; i < ARRAYSIZE(_sceneAnimTable); ++i) { - free(_sceneAnimTable[i]); + delete [] _sceneAnimTable[i]; } } @@ -463,15 +463,15 @@ void KyraEngine::startup() { // XXX for (int i = 0; i < 0x0C; ++i) { int size = _screen->getRectSize(3, 24); - _shapes[365+i] = (byte*)malloc(size); + _shapes[365+i] = new byte[size]; } - _shapes[0] = (uint8*)malloc(_screen->getRectSize(3, 24)); + _shapes[0] = new uint8[_screen->getRectSize(3, 24)]; memset(_shapes[0], 0, _screen->getRectSize(3, 24)); - _shapes[1] = (uint8*)malloc(_screen->getRectSize(4, 32)); + _shapes[1] = new uint8[_screen->getRectSize(4, 32)]; memset(_shapes[1], 0, _screen->getRectSize(4, 32)); - _shapes[2] = (uint8*)malloc(_screen->getRectSize(8, 69)); + _shapes[2] = new uint8[_screen->getRectSize(8, 69)]; memset(_shapes[2], 0, _screen->getRectSize(8, 69)); - _shapes[3] = (uint8*)malloc(_screen->getRectSize(8, 69)); + _shapes[3] = new uint8[_screen->getRectSize(8, 69)]; memset(_shapes[3], 0, _screen->getRectSize(8, 69)); for (int i = 0; i < _roomTableSize; ++i) { for (int item = 0; item < 12; ++item) { @@ -764,7 +764,7 @@ void KyraEngine::setupShapes123(const Shape *shapeTable, int endShape, int flags void KyraEngine::freeShapes123() { debugC(9, kDebugLevelMain, "KyraEngine::freeShapes123()"); for (int i = 123; i <= 172; ++i) { - free(_shapes[4+i]); + delete [] _shapes[4+i]; _shapes[4+i] = NULL; } } diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp index 5785a801a2..4de6a0ed15 100644 --- a/engines/kyra/screen.cpp +++ b/engines/kyra/screen.cpp @@ -1646,8 +1646,8 @@ uint8 *Screen::encodeShape(int x, int y, int w, int h, int flags) { static uint8 table[274]; int tableIndex = 0; - uint8 *newShape = NULL; - newShape = (uint8*)malloc(shapeSize+16); + uint8 *newShape = 0; + newShape = new uint8[shapeSize+16]; assert(newShape); byte *dst = newShape; @@ -1741,8 +1741,11 @@ uint8 *Screen::encodeShape(int x, int y, int w, int h, int flags) { int16 size = encodeShapeAndCalculateSize(_animBlockPtr, shapePtrBackUp, shapeSize2); if (size > shapeSize2) { shapeSize -= shapeSize2 - size; - newShape = (uint8*)realloc(newShape, shapeSize); - assert(newShape); + uint8 *newShape2 = new uint8[shapeSize]; + assert(newShape2); + memcpy(newShape2, newShape, shapeSize); + delete [] newShape; + newShape = newShape2; } else { dst = shapePtrBackUp; src = _animBlockPtr; diff --git a/engines/kyra/seqplayer.cpp b/engines/kyra/seqplayer.cpp index 7ee91e91aa..e954f529d4 100644 --- a/engines/kyra/seqplayer.cpp +++ b/engines/kyra/seqplayer.cpp @@ -82,7 +82,7 @@ uint8 *SeqPlayer::setPanPages(int pageNum, int shape) { if (offs != 0) { data += offs; uint16 sz = READ_LE_UINT16(data + 6); - panPage = (uint8 *)malloc(sz); + panPage = new uint8[sz]; if (panPage) { memcpy(panPage, data, sz); } @@ -96,7 +96,7 @@ void SeqPlayer::makeHandShapes() { _screen->loadBitmap("WRITING.CPS", 3, 3, 0); for (int i = 0; i < ARRAYSIZE(_handShapes); ++i) { if (_handShapes[i]) - free(_handShapes[i]); + delete [] _handShapes[i]; _handShapes[i] = setPanPages(3, i); } } @@ -104,7 +104,7 @@ void SeqPlayer::makeHandShapes() { void SeqPlayer::freeHandShapes() { debugC( 9, kDebugLevelSequence, "SeqPlayer::freeHandShapes()"); for (int i = 0; i < ARRAYSIZE(_handShapes); ++i) { - free(_handShapes[i]); + delete [] _handShapes[i]; _handShapes[i] = 0; } } diff --git a/engines/kyra/sequences_v1.cpp b/engines/kyra/sequences_v1.cpp index 31f4ffc853..11da73925b 100644 --- a/engines/kyra/sequences_v1.cpp +++ b/engines/kyra/sequences_v1.cpp @@ -1653,7 +1653,7 @@ void KyraEngine::freePanPages() { delete _endSequenceBackUpRect; _endSequenceBackUpRect = 0; for (int i = 0; i <= 19; ++i) { - free(_panPagesTable[i]); + delete [] _panPagesTable[i]; _panPagesTable[i] = NULL; } } diff --git a/engines/kyra/sprites.cpp b/engines/kyra/sprites.cpp index c16f891735..4a6f8f199f 100644 --- a/engines/kyra/sprites.cpp +++ b/engines/kyra/sprites.cpp @@ -48,11 +48,11 @@ Sprites::Sprites(KyraEngine *engine, OSystem *system) { } Sprites::~Sprites() { - delete[] _dat; + delete [] _dat; freeSceneShapes(); for (int i = 0; i < MAX_NUM_ANIMS; i++) { if (_anims[i].background) - free(_anims[i].background); + delete [] _anims[i].background; } } @@ -62,7 +62,7 @@ void Sprites::setupSceneAnims() { for (int i = 0; i < MAX_NUM_ANIMS; i++) { if (_anims[i].background) { - free(_anims[i].background); + delete [] _anims[i].background; _anims[i].background = 0; } @@ -118,10 +118,9 @@ void Sprites::setupSceneAnims() { if (_anims[i].height2 > 0) bkgdHeight += _anims[i].height2; - _anims[i].background = (uint8 *)malloc(_screen->getRectSize(bkgdWidth + 1, bkgdHeight)); - memset(_anims[i].background, 0, _screen->getRectSize(bkgdWidth + 1, bkgdHeight)); - + _anims[i].background = new uint8[_screen->getRectSize(bkgdWidth + 1, bkgdHeight)]; assert(_anims[i].background); + memset(_anims[i].background, 0, _screen->getRectSize(bkgdWidth + 1, bkgdHeight)); } } } @@ -492,7 +491,7 @@ void Sprites::loadDAT(const char *filename, SceneExits &exits) { void Sprites::freeSceneShapes() { debugC(9, kDebugLevelSprites, "Sprites::freeSceneShapes()"); for (int i = 0; i < ARRAYSIZE(_sceneShapes); i++ ) { - free(_sceneShapes[i]); + delete [] _sceneShapes[i]; _sceneShapes[i] = 0; } } |