diff options
author | Strangerke | 2015-12-01 08:44:57 +0100 |
---|---|---|
committer | Willem Jan Palenstijn | 2015-12-23 21:33:46 +0100 |
commit | 611df0c0dc7e98281fea354e20f74114fd94bee8 (patch) | |
tree | b16ef6b058d2187d13859f4ec3f57332dde56d5e /engines/lab | |
parent | 609fd323d39035ea0ca02377ad8e0fdadd30e1a1 (diff) | |
download | scummvm-rg350-611df0c0dc7e98281fea354e20f74114fd94bee8.tar.gz scummvm-rg350-611df0c0dc7e98281fea354e20f74114fd94bee8.tar.bz2 scummvm-rg350-611df0c0dc7e98281fea354e20f74114fd94bee8.zip |
LAB: Some renaming in allocroom, remove useless code and variables
Diffstat (limited to 'engines/lab')
-rw-r--r-- | engines/lab/allocroom.cpp | 31 | ||||
-rw-r--r-- | engines/lab/labfile.cpp | 32 |
2 files changed, 26 insertions, 37 deletions
diff --git a/engines/lab/allocroom.cpp b/engines/lab/allocroom.cpp index a95aa8e68f..22617cb774 100644 --- a/engines/lab/allocroom.cpp +++ b/engines/lab/allocroom.cpp @@ -35,34 +35,21 @@ namespace Lab { /* Have to make sure that ROOMBUFFERSIZE is bigger than the biggest piece of memory that we need */ #define ROOMBUFFERSIZE (2 * 20480L) -#define EMPTYROOM ((uint16) -1) -#define MAXMARKERS 10 extern RoomData *_rooms; -typedef struct { - uint16 _roomNum; - void *_start0, *_end0, *_start1, *_end1; -} RoomMarker; - -static RoomMarker _roomMarkers[MAXMARKERS]; -static void *RoomBuffer = NULL; -static uint16 CurMarker = 0; -static void *MemPlace = NULL, *NextMemPlace = NULL; -static int32 MemLeftInBuffer = 0L; +static void *_roomBuffer = nullptr; +static uint16 _curMarker = 0; +static void *_memPlace = nullptr; /*****************************************************************************/ /* Allocates the memory for the room buffers. */ /*****************************************************************************/ bool initRoomBuffer() { - CurMarker = 0; - - if ((RoomBuffer = calloc(ROOMBUFFERSIZE, 1))) { - MemPlace = RoomBuffer; - MemLeftInBuffer = ROOMBUFFERSIZE; + _curMarker = 0; - for (uint16 i = 0; i < MAXMARKERS; i++) - _roomMarkers[i]._roomNum = EMPTYROOM; + if ((_roomBuffer = calloc(ROOMBUFFERSIZE, 1))) { + _memPlace = _roomBuffer; return true; } else @@ -73,8 +60,10 @@ bool initRoomBuffer() { /* Frees the memory for the room buffers. */ /*****************************************************************************/ void freeRoomBuffer() { - if (RoomBuffer) - free(RoomBuffer); + if (_roomBuffer) { + free(_roomBuffer); + _roomBuffer = nullptr; + } } } // End of namespace Lab diff --git a/engines/lab/labfile.cpp b/engines/lab/labfile.cpp index 31d10905d1..83f3b0f2e9 100644 --- a/engines/lab/labfile.cpp +++ b/engines/lab/labfile.cpp @@ -53,8 +53,8 @@ struct FileMarker { static FileMarker FileMarkers[MAXMARKERS]; -static uint16 CurMarker = 0; -static void *MemPlace = NULL; +static uint16 _curMarker = 0; +static void *_memPlace = NULL; @@ -79,17 +79,17 @@ static void freeFile(uint16 RMarker) { static void *getCurMemLabFile(uint32 size) { void *ptr = 0; - if ((((char *) MemPlace) + size - 1) >= + if ((((char *) _memPlace) + size - 1) >= (((char *) buffer) + buffersize)) - MemPlace = buffer; + _memPlace = buffer; - ptr = MemPlace; - MemPlace = (char *)MemPlace + size; + ptr = _memPlace; + _memPlace = (char *)_memPlace + size; for (int i = 0; i < MAXMARKERS; i++) { if (FileMarkers[i].name[0]) { - if ( ((FileMarkers[i].Start >= ptr) && (FileMarkers[i].Start < MemPlace)) - || ((FileMarkers[i].End >= ptr) && (FileMarkers[i].End < MemPlace)) + if ( ((FileMarkers[i].Start >= ptr) && (FileMarkers[i].Start < _memPlace)) + || ((FileMarkers[i].End >= ptr) && (FileMarkers[i].End < _memPlace)) || ((ptr >= FileMarkers[i].Start) && (ptr <= FileMarkers[i].End))) freeFile(i); } @@ -139,11 +139,11 @@ bool allocFile(void **Ptr, uint32 Size, const char *fileName) { return true; } - RMarker = CurMarker; - CurMarker++; + RMarker = _curMarker; + _curMarker++; - if (CurMarker >= MAXMARKERS) - CurMarker = 0; + if (_curMarker >= MAXMARKERS) + _curMarker = 0; freeFile(RMarker); strcpy(FileMarkers[RMarker].name, fileName); @@ -204,9 +204,9 @@ void readBlock(void *Buffer, uint32 Size, byte **File) { void resetBuffer() { uint16 RMarker; - CurMarker = 0; + _curMarker = 0; RMarker = 0; - MemPlace = buffer; + _memPlace = buffer; while (RMarker < MAXMARKERS) { freeFile(RMarker); @@ -276,7 +276,7 @@ void *stealBufMem(int32 Size) { buffer += Size; buffersize -= Size; - MemPlace = buffer; + _memPlace = buffer; return Mem; } @@ -306,7 +306,7 @@ void freeAllStolenMem() { buffer = realbufferstart; buffersize = realbuffersize; - MemPlace = buffer; + _memPlace = buffer; } } // End of namespace Lab |