[Scummvm-git-logs] scummvm master -> 62e0d10d999e1d06ef776183a8dcfaaeb9fb90d1
Strangerke
noreply at scummvm.org
Thu May 9 08:33:52 UTC 2024
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
62e0d10d99 BAGEL: Remove useless defines giving Bof names to memset, memcpy and memmove
Commit: 62e0d10d999e1d06ef776183a8dcfaaeb9fb90d1
https://github.com/scummvm/scummvm/commit/62e0d10d999e1d06ef776183a8dcfaaeb9fb90d1
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-09T09:33:44+01:00
Commit Message:
BAGEL: Remove useless defines giving Bof names to memset, memcpy and memmove
Changed paths:
engines/bagel/baglib/master_win.cpp
engines/bagel/baglib/save_game_file.cpp
engines/bagel/boflib/dat_file.cpp
engines/bagel/boflib/gfx/bitmap.cpp
engines/bagel/boflib/misc.cpp
engines/bagel/boflib/misc.h
engines/bagel/boflib/res.cpp
engines/bagel/boflib/string.cpp
engines/bagel/boflib/string_functions.cpp
engines/bagel/spacebar/sraf_computer.cpp
diff --git a/engines/bagel/baglib/master_win.cpp b/engines/bagel/baglib/master_win.cpp
index e9f7ae5b750..da255949646 100644
--- a/engines/bagel/baglib/master_win.cpp
+++ b/engines/bagel/baglib/master_win.cpp
@@ -375,7 +375,7 @@ ErrorCode CBagMasterWin::loadFile(const CBofString &wldName, const CBofString &s
_objList = (StObj *)bofAlloc(MAX_OBJS * sizeof(StObj));
if (_objList != nullptr) {
// Init to zero (we might not use all slots)
- bofMemSet(_objList, 0, MAX_OBJS * sizeof(StObj));
+ memset(_objList, 0, MAX_OBJS * sizeof(StObj));
} else {
reportError(ERR_MEMORY, "Could not allocate Object list");
@@ -1412,7 +1412,7 @@ void CBagMasterWin::fillSaveBuffer(StBagelSave *saveBuf) {
//
// 1st, wipe it
- bofMemSet(saveBuf, 0, sizeof(StBagelSave));
+ memset(saveBuf, 0, sizeof(StBagelSave));
CBagel *app = CBagel::getBagApp();
if (app != nullptr) {
@@ -1488,7 +1488,7 @@ void CBagMasterWin::fillSaveBuffer(StBagelSave *saveBuf) {
assert(_objList != nullptr);
- bofMemCopy(&saveBuf->_stObjListEx[0], _objList, sizeof(StObj) * MAX_OBJS);
+ memcpy(&saveBuf->_stObjListEx[0], _objList, sizeof(StObj) * MAX_OBJS);
saveBuf->_bUseEx = 1;
}
@@ -1648,14 +1648,14 @@ void CBagMasterWin::doRestore(StBagelSave *saveBuf) {
_objList = (StObj *)bofAlloc(MAX_OBJS * sizeof(StObj));
if (_objList != nullptr) {
// Init to nullptr (might not use all slots)
- bofMemSet(_objList, 0, MAX_OBJS * sizeof(StObj));
+ memset(_objList, 0, MAX_OBJS * sizeof(StObj));
} else {
reportError(ERR_MEMORY);
}
}
- bofMemCopy(getObjList(), &saveBuf->_stObjListEx[0], sizeof(StObj) * MAX_OBJS);
+ memcpy(getObjList(), &saveBuf->_stObjListEx[0], sizeof(StObj) * MAX_OBJS);
if (saveBuf->_bUseEx) {
setSaveObjs(true);
diff --git a/engines/bagel/baglib/save_game_file.cpp b/engines/bagel/baglib/save_game_file.cpp
index ce0515ea4e1..dbce48aa2d5 100644
--- a/engines/bagel/baglib/save_game_file.cpp
+++ b/engines/bagel/baglib/save_game_file.cpp
@@ -237,7 +237,7 @@ ErrorCode CBagSaveGameFile::readTitle(int32 lSlot, StSavegameHeader *pSavedGame)
readRecord(lRecNum, pBuf);
// Fill StSavegameHeader structure with this game's saved info
- bofMemCopy(pSavedGame, pBuf, sizeof(StSavegameHeader));
+ memcpy(pSavedGame, pBuf, sizeof(StSavegameHeader));
bofFree(pBuf);
} else {
@@ -265,7 +265,7 @@ ErrorCode CBagSaveGameFile::readTitleOnly(int32 lSlot, char *pGameTitle) {
readFromFile(lRecNum, pBuf, lSize);
// Fill with current game title
- bofMemCopy(pGameTitle, pBuf, lSize);
+ memcpy(pGameTitle, pBuf, lSize);
} else {
reportError(ERR_UNKNOWN, "Unable to find saved game #%ld in %s", lSlot, _szFileName);
diff --git a/engines/bagel/boflib/dat_file.cpp b/engines/bagel/boflib/dat_file.cpp
index 0bf6d000b22..39481c19bb3 100644
--- a/engines/bagel/boflib/dat_file.cpp
+++ b/engines/bagel/boflib/dat_file.cpp
@@ -666,7 +666,7 @@ ErrorCode CBofDataFile::addRecord(void *pBuf, int32 lLength, bool bUpdateHeader,
HEADER_REC *pTmpHeader = new HEADER_REC[(int)_lNumRecs];
if (pTmpHeader != nullptr) {
if (_pHeader != nullptr) {
- bofMemCopy(pTmpHeader, _pHeader, (size_t)(HEADER_REC::size() * (_lNumRecs - 1)));
+ memcpy(pTmpHeader, _pHeader, (size_t)(HEADER_REC::size() * (_lNumRecs - 1)));
delete[] _pHeader;
}
@@ -716,7 +716,7 @@ ErrorCode CBofDataFile::deleteRecord(int32 lRecNum, bool bUpdateHeader) {
_lHeaderStart -= _pHeader[(int)lRecNum]._lLength;
// Header has changed size
- bofMemMove(_pHeader + lRecNum, _pHeader + lRecNum + 1, (size_t)((_lNumRecs - lRecNum - 1) * HEADER_REC::size()));
+ memmove(_pHeader + lRecNum, _pHeader + lRecNum + 1, (size_t)((_lNumRecs - lRecNum - 1) * HEADER_REC::size()));
// On less record
_lNumRecs--;
diff --git a/engines/bagel/boflib/gfx/bitmap.cpp b/engines/bagel/boflib/gfx/bitmap.cpp
index fa52861d530..ec6618a9d4b 100644
--- a/engines/bagel/boflib/gfx/bitmap.cpp
+++ b/engines/bagel/boflib/gfx/bitmap.cpp
@@ -396,7 +396,7 @@ ErrorCode CBofBitmap::paint1To1(CBofBitmap *pBmp) {
pBmp->lock();
// Direct 1 to 1 copy
- bofMemCopy(pBmp->_pBits, _pBits, _nScanDX * _nDY);
+ memcpy(pBmp->_pBits, _pBits, _nScanDX * _nDY);
pBmp->unlock();
unlock();
@@ -795,7 +795,7 @@ void CBofBitmap::line(int nSrcX, int nSrcY, int nDstX, int nDstY, byte iColor) {
// Horizontal lines are a special case that can be done optimally
if (nSrcY == nDstY) {
lock();
- bofMemSet(getPixelAddress(MIN(nSrcX, nDstX), nSrcY), iColor, ABS(nDstX - nSrcX));
+ memset(getPixelAddress(MIN(nSrcX, nDstX), nSrcY), iColor, ABS(nDstX - nSrcX));
unlock();
} else {
@@ -885,18 +885,18 @@ ErrorCode CBofBitmap::scrollRight(int nPixels, CBofRect * /*pRect*/) {
if (nPixels > 0) {
for (int i = 0; i < _nDY; i++) {
- bofMemCopy(pTemp, p + nBytes, nPixels);
- bofMemMove(p + nPixels, p, nBytes);
- bofMemCopy(p, pTemp, nPixels);
+ memcpy(pTemp, p + nBytes, nPixels);
+ memmove(p + nPixels, p, nBytes);
+ memcpy(p, pTemp, nPixels);
p += _nScanDX;
}
} else {
nPixels = -nPixels;
for (int i = 0; i < _nDY; i++) {
- bofMemCopy(pTemp, p, nPixels);
- bofMemMove(p, p + nPixels, nBytes);
- bofMemCopy(p + nBytes, pTemp, nPixels);
+ memcpy(pTemp, p, nPixels);
+ memmove(p, p + nPixels, nBytes);
+ memcpy(p + nBytes, pTemp, nPixels);
p += _nScanDX;
}
}
@@ -976,7 +976,7 @@ ErrorCode CBofBitmap::scrollUp(int nPixels, CBofRect *pRect) {
byte *pCurRow = pStart;
// Copy 1st row into temp row buffer
- bofMemCopy(pRowBuf, pCurRow, dx);
+ memcpy(pRowBuf, pCurRow, dx);
int32 lJump = dx1 * nPixels;
@@ -987,7 +987,7 @@ ErrorCode CBofBitmap::scrollUp(int nPixels, CBofRect *pRect) {
// Working row by row
for (int32 i = 1; i < dy; i++) {
// Copy this row to row above it
- bofMemCopy(pLastRow, pCurRow, dx);
+ memcpy(pLastRow, pCurRow, dx);
pLastRow = pCurRow;
@@ -1000,13 +1000,13 @@ ErrorCode CBofBitmap::scrollUp(int nPixels, CBofRect *pRect) {
i++;
// Copy 1st row into this row
- bofMemCopy(pLastRow, pRowBuf, dx);
+ memcpy(pLastRow, pRowBuf, dx);
pCurRow += dx1;
p1stRow = pLastRow = pCurRow;
// Copy this next row into temp row buffer
- bofMemCopy(pRowBuf, p1stRow, dx);
+ memcpy(pRowBuf, p1stRow, dx);
pCurRow += lJump;
}
@@ -1014,7 +1014,7 @@ ErrorCode CBofBitmap::scrollUp(int nPixels, CBofRect *pRect) {
}
// Copy 1st row into last row
- bofMemCopy(pLastRow, pRowBuf, dx);
+ memcpy(pLastRow, pRowBuf, dx);
bofFree(pRowBuf);
@@ -1034,7 +1034,6 @@ ErrorCode CBofBitmap::scrollUp(int nPixels, CBofRect *pRect) {
#define BIT16 0x00010000
#define BIT17 0x00020000
#define SEQ (BIT17)
-#define BLOCK 4
ErrorCode CBofBitmap::fadeIn(CBofWindow *pWnd, int xStart, int yStart, int nMaskColor, int nBlockSize, int /*nSpeed*/) {
assert(isValidObject(this));
diff --git a/engines/bagel/boflib/misc.cpp b/engines/bagel/boflib/misc.cpp
index a41a685059c..cd08180cc5d 100644
--- a/engines/bagel/boflib/misc.cpp
+++ b/engines/bagel/boflib/misc.cpp
@@ -67,7 +67,7 @@ void *bofMemAlloc(uint32 nSize, const char *pFile, int nLine, bool bClear) {
// If allocation was successful, then we're outta here
if (pNewBlock != nullptr) {
if (bClear)
- bofMemSet((byte *)pNewBlock, 0, nSize);
+ memset((byte *)pNewBlock, 0, nSize);
break;
}
diff --git a/engines/bagel/boflib/misc.h b/engines/bagel/boflib/misc.h
index bf6988e1a57..af3ac4081cf 100644
--- a/engines/bagel/boflib/misc.h
+++ b/engines/bagel/boflib/misc.h
@@ -86,10 +86,6 @@ extern void bofMemFree(void *pBuf, const char *pFile, int nLine);
#define bofCAlloc(n, m) bofMemAlloc((uint32)(n) * (m), __FILE__, __LINE__, true)
#define bofFree(p) bofMemFree((p), __FILE__, __LINE__)
-#define bofMemSet memset
-#define bofMemCopy memcpy
-#define bofMemMove memmove
-
inline uint32 getFreePhysMem() {
return 999999;
}
diff --git a/engines/bagel/boflib/res.cpp b/engines/bagel/boflib/res.cpp
index f71c813f274..5ddfd9cbe58 100644
--- a/engines/bagel/boflib/res.cpp
+++ b/engines/bagel/boflib/res.cpp
@@ -53,8 +53,9 @@ ErrorCode CBofStringTable::load(const char *pszFileName) {
assert(_lBufSize > 0);
// Allocate a buffer to hold entire file
- if ((_pBuf = (byte *)bofAlloc(_lBufSize + 1)) != nullptr) {
- bofMemSet(_pBuf, 0, _lBufSize + 1);
+ _pBuf = (byte *)bofAlloc(_lBufSize + 1);
+ if (_pBuf != nullptr) {
+ memset(_pBuf, 0, _lBufSize + 1);
// Read in entire file
read(_pBuf, _lBufSize);
diff --git a/engines/bagel/boflib/string.cpp b/engines/bagel/boflib/string.cpp
index c9fb11b1a60..2c145f4e493 100644
--- a/engines/bagel/boflib/string.cpp
+++ b/engines/bagel/boflib/string.cpp
@@ -71,10 +71,8 @@ CBofString::CBofString(char ch, int nRepeat) {
assert(nRepeat > 0);
init();
-
allocBuffer(nRepeat);
-
- bofMemSet(_pszData, ch, nRepeat);
+ memset(_pszData, ch, nRepeat);
}
CBofString::~CBofString() {
@@ -104,11 +102,11 @@ void CBofString::allocBuffer(int nLen) {
free();
// Don't do anything about zero length allocations
- if (nLen) {
-
- if ((_pszData = (char *)bofAlloc(nLen + 1)) != nullptr) {
+ if (nLen > 0) {
+ _pszData = (char *)bofAlloc(nLen + 1);
+ if (_pszData != nullptr) {
// Set the entire buffer to nullptr
- bofMemSet(_pszData, '\0', nLen + 1);
+ memset(_pszData, '\0', nLen + 1);
}
}
@@ -179,7 +177,7 @@ void CBofString::allocCopy(CBofString &dest, int nCopyLen, int nCopyIndex, int n
dest.allocBuffer(nNewLen);
assert(_pszData != nullptr);
- bofMemCopy(dest._pszData, &_pszData[nCopyIndex], nCopyLen * sizeof(char));
+ memcpy(dest._pszData, &_pszData[nCopyIndex], nCopyLen * sizeof(char));
}
}
@@ -206,8 +204,8 @@ void CBofString::concatCopy(int nSrc1Len, const char *lpszSrc1Data, int nSrc2Len
int nNewLen = nSrc1Len + nSrc2Len;
allocBuffer((nAllocLen == 0 ? nNewLen : nAllocLen));
- bofMemCopy(_pszData, lpszSrc1Data, nSrc1Len * sizeof(char));
- bofMemCopy(&_pszData[nSrc1Len], lpszSrc2Data, nSrc2Len * sizeof(char));
+ memcpy(_pszData, lpszSrc1Data, nSrc1Len * sizeof(char));
+ memcpy(&_pszData[nSrc1Len], lpszSrc2Data, nSrc2Len * sizeof(char));
// RMS
_nLength = (uint16)nNewLen;
}
@@ -251,7 +249,7 @@ void CBofString::concatInPlace(int nSrcLen, const char *lpszSrcData) {
if (NORMALIZEBUFFERSIZE() == 0) {
allocBuffer(_nLength + nAllocAmount);
- bofMemCopy(_pszData, lpszSrcData, nSrcLen);
+ memcpy(_pszData, lpszSrcData, nSrcLen);
*(_pszData + nSrcLen) = '\0';
_nLength = (uint16)(_nLength + (uint16)nSrcLen);
@@ -272,7 +270,7 @@ void CBofString::concatInPlace(int nSrcLen, const char *lpszSrcData) {
lpszOldData = new char[_nLength + nSrcLen + 1];
if (lpszOldData != nullptr) {
- bofMemCopy(lpszOldData, _pszData, (_nLength /*+ nSrcLen*/ + 1) * sizeof(char));
+ memcpy(lpszOldData, _pszData, (_nLength /*+ nSrcLen*/ + 1) * sizeof(char));
concatCopy(_nLength, lpszOldData, nSrcLen, lpszSrcData, _nLength + nAllocAmount);
@@ -288,7 +286,7 @@ void CBofString::concatInPlace(int nSrcLen, const char *lpszSrcData) {
if (nSrcLen == 1) {
_pszData[_nLength] = *lpszSrcData;
} else {
- bofMemCopy(&_pszData[_nLength], lpszSrcData, nSrcLen * sizeof(char));
+ memcpy(&_pszData[_nLength], lpszSrcData, nSrcLen * sizeof(char));
}
_nLength = (uint16)(_nLength + (uint16)nSrcLen);
}
diff --git a/engines/bagel/boflib/string_functions.cpp b/engines/bagel/boflib/string_functions.cpp
index 2dd83f920c1..e2821fc450a 100644
--- a/engines/bagel/boflib/string_functions.cpp
+++ b/engines/bagel/boflib/string_functions.cpp
@@ -77,7 +77,7 @@ char *strreplaceStr(char *pszBuf, const char *pszTok, const char *pszNewTok) {
if (nDiff != 0) {
memmove(pszEndTok - nDiff, pszEndTok, strlen(pszEndTok) + 1);
}
- bofMemCopy(pszSearch, pszNewTok, nNewTok);
+ memcpy(pszSearch, pszNewTok, nNewTok);
}
return pszBuf;
diff --git a/engines/bagel/spacebar/sraf_computer.cpp b/engines/bagel/spacebar/sraf_computer.cpp
index 319e74a7730..1e921cb9b94 100644
--- a/engines/bagel/spacebar/sraf_computer.cpp
+++ b/engines/bagel/spacebar/sraf_computer.cpp
@@ -4184,7 +4184,7 @@ void SrafComputer::notifyBoss(CBofString &sSoundFile, int nStafferID) {
int nLength = fTxtFile.getLength();
if (nLength != 0 && (pszBuf = (char *)bofAlloc(nLength + 1)) != nullptr) {
- bofMemSet(pszBuf, 0, nLength + 1);
+ memset(pszBuf, 0, nLength + 1);
fTxtFile.read(pszBuf, nLength);
// Put it up on the screen
More information about the Scummvm-git-logs
mailing list