mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-21 19:51:49 +00:00
Adding a strdup-like inline function
svn-id: r40216
This commit is contained in:
parent
df9932669a
commit
ae46e8e1ca
@ -67,8 +67,7 @@ void DemoPlayer::playVideo(const char *fileName) {
|
||||
uint32 waitTime = 0;
|
||||
char *file, *filePtr;
|
||||
|
||||
file = filePtr = new char[strlen(fileName) + 1];
|
||||
strcpy(file, fileName);
|
||||
file = filePtr = strdupcpy(fileName);
|
||||
|
||||
// Trimming spaces front
|
||||
while (*file == ' ')
|
||||
@ -121,13 +120,8 @@ void DemoPlayer::playVideoNormal() {
|
||||
}
|
||||
|
||||
void DemoPlayer::playVideoDoubled() {
|
||||
const char *fileNameOpened;
|
||||
char *fileName;
|
||||
|
||||
fileNameOpened = _vm->_vidPlayer->getFileName();
|
||||
|
||||
fileName = new char[strlen(fileNameOpened) + 1];
|
||||
strcpy(fileName, fileNameOpened);
|
||||
const char *fileNameOpened = _vm->_vidPlayer->getFileName();
|
||||
char *fileName = strdupcpy(fileNameOpened);
|
||||
|
||||
_vm->_vidPlayer->primaryClose();
|
||||
|
||||
|
@ -3147,21 +3147,15 @@ bool GobMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameD
|
||||
namespace Gob {
|
||||
|
||||
void GobEngine::initGame(const GOBGameDescription *gd) {
|
||||
if (gd->startTotBase == 0) {
|
||||
_startTot = new char[10];
|
||||
strcpy(_startTot, "intro.tot");
|
||||
} else {
|
||||
_startTot = new char[strlen(gd->startTotBase) + 1];
|
||||
strcpy(_startTot, gd->startTotBase);
|
||||
}
|
||||
if (gd->startTotBase == 0)
|
||||
_startTot = strdupcpy("intro.tot");
|
||||
else
|
||||
_startTot = strdupcpy(gd->startTotBase);
|
||||
|
||||
if (gd->startStkBase == 0) {
|
||||
_startStk = new char[10];
|
||||
strcpy(_startStk, "intro.stk");
|
||||
} else {
|
||||
_startStk = new char[strlen(gd->startStkBase) + 1];
|
||||
strcpy(_startStk, gd->startStkBase);
|
||||
}
|
||||
if (gd->startStkBase == 0)
|
||||
_startStk = strdupcpy("intro.stk");
|
||||
else
|
||||
_startStk = strdupcpy(gd->startStkBase);
|
||||
|
||||
_gameType = gd->gameType;
|
||||
_features = gd->features;
|
||||
|
@ -135,6 +135,19 @@ inline char *strncpy0(char *dest, const char *src, size_t n) {
|
||||
return dest;
|
||||
}
|
||||
|
||||
inline char *strdupcpy(const char *str) {
|
||||
if (!str)
|
||||
return 0;
|
||||
|
||||
size_t len = strlen(str) + 1;
|
||||
|
||||
char *nstr = new char[len];
|
||||
|
||||
memcpy(nstr, str, len);
|
||||
|
||||
return nstr;
|
||||
}
|
||||
|
||||
// A "smart" reference counting templated class
|
||||
template<typename T>
|
||||
class ReferenceCounter {
|
||||
|
@ -77,8 +77,7 @@ bool VideoPlayer::Video::open(const char *fileName, Type which) {
|
||||
return false;
|
||||
}
|
||||
|
||||
_fileName = new char[strlen(fileName) + 1];
|
||||
strcpy(_fileName, fileName);
|
||||
_fileName = strdupcpy(fileName);
|
||||
|
||||
_defaultX = _video->getX();
|
||||
_defaultY = _video->getY();
|
||||
|
Loading…
x
Reference in New Issue
Block a user