DEVTOOLS: Use nullptr

Using clang-tidy modernize-use-nullptr
This commit is contained in:
Orgad Shaneh 2021-11-13 23:34:17 +02:00 committed by Filippos Karapetis
parent cb61ec37c4
commit 62797daf3c
31 changed files with 213 additions and 213 deletions

View file

@ -66,8 +66,8 @@ struct BdfFont {
BdfBoundingBox *boxes;
void reset() {
familyName = 0;
slant = 0;
familyName = nullptr;
slant = nullptr;
maxAdvance = 0;
size = 0;
height = 0;
@ -78,9 +78,9 @@ struct BdfFont {
defaultCharacter = 0;
numCharacters = 0;
bitmaps = 0;
advances = 0;
boxes = 0;
bitmaps = nullptr;
advances = nullptr;
boxes = nullptr;
}
BdfFont() {
@ -231,7 +231,7 @@ int main(int argc, char *argv[]) {
int encoding = -1;
int xAdvance;
unsigned char *bitmap = 0;
unsigned char *bitmap = nullptr;
BdfBoundingBox bbox = font.defaultBox;
while (true) {
@ -347,13 +347,13 @@ int main(int argc, char *argv[]) {
// Free the advance table, in case all glyphs use the same advance
if (hasFixedAdvance) {
delete[] font.advances;
font.advances = 0;
font.advances = nullptr;
}
// Free the box table, in case all glyphs use the same box
if (hasFixedBBox) {
delete[] font.boxes;
font.boxes = 0;
font.boxes = nullptr;
}
// Adapt for the fact that we never use encoding 0.
@ -367,10 +367,10 @@ int main(int argc, char *argv[]) {
// Try to compact the tables
if (charsAvailable < font.numCharacters) {
unsigned char **bitmaps = new unsigned char *[charsAvailable];
BdfBoundingBox *boxes = 0;
BdfBoundingBox *boxes = nullptr;
if (!hasFixedBBox)
boxes = new BdfBoundingBox[charsAvailable];
unsigned char *advances = 0;
unsigned char *advances = nullptr;
if (!hasFixedAdvance)
advances = new unsigned char[charsAvailable];
@ -384,7 +384,7 @@ int main(int argc, char *argv[]) {
if (!hasFixedAdvance)
advances[i] = font.advances[encoding];
} else {
bitmaps[i] = 0;
bitmaps[i] = nullptr;
}
}
@ -399,7 +399,7 @@ int main(int argc, char *argv[]) {
}
char dateBuffer[256];
time_t curTime = time(0);
time_t curTime = time(nullptr);
snprintf(dateBuffer, sizeof(dateBuffer), "%s", ctime(&curTime));
// Finally output the cpp source file to stdout

View file

@ -855,7 +855,7 @@ int main(int argc, char *argv[]) {
FILE* src_file;
char buf[2];
src_file = fopen("btn_1.bmp", "rb");
if (src_file == NULL) {
if (src_file == nullptr) {
perror("btn_1.bmp");
fclose(outFile);
return -1;
@ -871,7 +871,7 @@ int main(int argc, char *argv[]) {
fclose(src_file);
src_file = fopen("btn_1_off.bmp", "rb");
if (src_file == NULL) {
if (src_file == nullptr) {
perror("btn_1_off.bmp");
fclose(outFile);
return -1;
@ -887,7 +887,7 @@ int main(int argc, char *argv[]) {
fclose(src_file);
src_file = fopen("btn_2.bmp", "rb");
if (src_file == NULL) {
if (src_file == nullptr) {
perror("btn_2.bmp");
fclose(outFile);
return -1;
@ -903,7 +903,7 @@ int main(int argc, char *argv[]) {
fclose(src_file);
src_file = fopen("btn_2_off.bmp", "rb");
if (src_file == NULL) {
if (src_file == nullptr) {
perror("btn_2_off.bmp");
fclose(outFile);
return -1;
@ -919,7 +919,7 @@ int main(int argc, char *argv[]) {
fclose(src_file);
src_file = fopen("btn_3.bmp", "rb");
if (src_file == NULL) {
if (src_file == nullptr) {
perror("btn_3.bmp");
fclose(outFile);
return -1;
@ -935,7 +935,7 @@ int main(int argc, char *argv[]) {
fclose(src_file);
src_file = fopen("btn_3_off.bmp", "rb");
if (src_file == NULL) {
if (src_file == nullptr) {
perror("btn_3_off.bmp");
fclose(outFile);
return -1;
@ -951,7 +951,7 @@ int main(int argc, char *argv[]) {
fclose(src_file);
src_file = fopen("btn_4.bmp", "rb");
if (src_file == NULL) {
if (src_file == nullptr) {
perror("btn_4.bmp");
fclose(outFile);
return -1;
@ -967,7 +967,7 @@ int main(int argc, char *argv[]) {
fclose(src_file);
src_file = fopen("btn_4_off.bmp", "rb");
if (src_file == NULL) {
if (src_file == nullptr) {
perror("btn_4_off.bmp");
fclose(outFile);
return -1;
@ -983,7 +983,7 @@ int main(int argc, char *argv[]) {
fclose(src_file);
src_file = fopen("btn_5.bmp", "rb");
if (src_file == NULL) {
if (src_file == nullptr) {
perror("btn_5.bmp");
fclose(outFile);
return -1;
@ -999,7 +999,7 @@ int main(int argc, char *argv[]) {
fclose(src_file);
src_file = fopen("btn_5_off.bmp", "rb");
if (src_file == NULL) {
if (src_file == nullptr) {
perror("btn_5_off.bmp");
fclose(outFile);
return -1;
@ -1015,7 +1015,7 @@ int main(int argc, char *argv[]) {
fclose(src_file);
src_file = fopen("btn_6.bmp", "rb");
if (src_file == NULL) {
if (src_file == nullptr) {
perror("btn_6.bmp");
fclose(outFile);
return -1;
@ -1031,7 +1031,7 @@ int main(int argc, char *argv[]) {
fclose(src_file);
src_file = fopen("btn_6_off.bmp", "rb");
if (src_file == NULL) {
if (src_file == nullptr) {
perror("btn_6_off.bmp");
fclose(outFile);
return -1;
@ -1047,7 +1047,7 @@ int main(int argc, char *argv[]) {
fclose(src_file);
src_file = fopen("btn_7.bmp", "rb");
if (src_file == NULL) {
if (src_file == nullptr) {
perror("btn_7.bmp");
fclose(outFile);
return -1;
@ -1063,7 +1063,7 @@ int main(int argc, char *argv[]) {
fclose(src_file);
src_file = fopen("btn_7_off.bmp", "rb");
if (src_file == NULL) {
if (src_file == nullptr) {
perror("btn_7_off.bmp");
fclose(outFile);
return -1;
@ -1079,7 +1079,7 @@ int main(int argc, char *argv[]) {
fclose(src_file);
src_file = fopen("btn_8.bmp", "rb");
if (src_file == NULL) {
if (src_file == nullptr) {
perror("btn_8.bmp");
fclose(outFile);
return -1;
@ -1095,7 +1095,7 @@ int main(int argc, char *argv[]) {
fclose(src_file);
src_file = fopen("btn_8_off.bmp", "rb");
if (src_file == NULL) {
if (src_file == nullptr) {
perror("btn_8_off.bmp");
fclose(outFile);
return -1;
@ -1111,7 +1111,7 @@ int main(int argc, char *argv[]) {
fclose(src_file);
src_file = fopen("btn_9.bmp", "rb");
if (src_file == NULL) {
if (src_file == nullptr) {
perror("btn_9.bmp");
fclose(outFile);
return -1;
@ -1127,7 +1127,7 @@ int main(int argc, char *argv[]) {
fclose(src_file);
src_file = fopen("btn_9_off.bmp", "rb");
if (src_file == NULL) {
if (src_file == nullptr) {
perror("btn_9_off.bmp");
fclose(outFile);
return -1;
@ -1263,7 +1263,7 @@ void writeScreenActs(FILE *outFile, const uint16 *screenActs[], int nbrElem) {
writeUint16BE(outFile, nbrElem);
for (int i = 0; i < nbrElem; i++) {
if (screenActs[i] == 0)
if (screenActs[i] == nullptr)
writeUint16BE(outFile, 0);
else {
nbrSubElem = 1;
@ -1283,7 +1283,7 @@ void writeObjectArray(FILE *outFile, const object_t objects[], int nbrElem) {
for (int i = 0; i < nbrElem; i++) {
writeUint16BE(outFile, objects[i].nounIndex);
writeUint16BE(outFile, objects[i].dataIndex);
if (objects[i].stateDataIndex == NULL)
if (objects[i].stateDataIndex == nullptr)
writeUint16BE(outFile, 0);
else {
nbrSubElem = 1;
@ -1337,7 +1337,7 @@ void writeActListArray(FILE *outFile, const actList actListArr[], int nbrElem) {
writeUint16BE(outFile, nbrElem);
for (int i = 0; i < nbrElem; i++) {
for (nbrSubElem = 0; actListArr[i][nbrSubElem] != NULL; nbrSubElem++)
for (nbrSubElem = 0; actListArr[i][nbrSubElem] != nullptr; nbrSubElem++)
;
writeUint16BE(outFile, nbrSubElem);
for (int j = 0; j < nbrSubElem; j++) {

View file

@ -1163,7 +1163,7 @@ const ExtractFilename *getFilenameDesc(const int id) {
if (i->id == id)
return i;
}
return 0;
return nullptr;
}
bool isLangSpecific(const int id) {

View file

@ -173,7 +173,7 @@ const Game * const gameDescs[] = {
lolGames,
eob1Games,
eob2Games,
0
nullptr
};
// Need tables
@ -4435,7 +4435,7 @@ const GameNeed gameNeedTable[] = {
//{ kEoB2, kPlatformPC98, kNoSpecial, eob2PC98Need },
{ kEoB2, kPlatformFMTowns, kNoSpecial, eob2FMTownsNeed },
{ -1, -1, -1, 0 }
{ -1, -1, -1, nullptr }
};
} // end of anonymous namespace
@ -4446,5 +4446,5 @@ const int *getNeedList(const Game *g) {
return need->entries;
}
return 0;
return nullptr;
}

View file

@ -228,7 +228,7 @@ bool md5_file(const char *name, uint8 digest[16], uint32 length) {
FILE *f;
f = fopen(name, "rb");
if (f == NULL) {
if (f == nullptr) {
printf("md5_file couldn't open '%s'\n", name);
return false;
}

View file

@ -31,7 +31,7 @@ bool PAKFile::loadFile(const char *file, const bool isAmiga) {
return true;
delete _fileList;
_fileList = 0;
_fileList = nullptr;
FILE *pakfile = fopen(file, "rb");
if (!pakfile)
@ -47,7 +47,7 @@ bool PAKFile::loadFile(const char *file, const bool isAmiga) {
fclose(pakfile);
const char *currentName = 0;
const char *currentName = nullptr;
uint32 startoffset = _isAmiga ? READ_BE_UINT32(buffer) : READ_LE_UINT32(buffer);
uint32 endoffset = 0;
@ -73,7 +73,7 @@ bool PAKFile::loadFile(const char *file, const bool isAmiga) {
assert(data);
memcpy(data, buffer + startoffset, endoffset - startoffset);
addFile(currentName, data, endoffset - startoffset);
data = 0;
data = nullptr;
if (endoffset == filesize)
break;
@ -152,7 +152,7 @@ bool PAKFile::outputAllFiles() {
}
bool PAKFile::outputFileAs(const char *f, const char *fn) {
FileList *cur = (_fileList != 0) ? _fileList->findEntry(f) : 0;
FileList *cur = (_fileList != nullptr) ? _fileList->findEntry(f) : nullptr;
if (!cur) {
error("file '%s' not found", f);
@ -177,10 +177,10 @@ bool PAKFile::outputFileAs(const char *f, const char *fn) {
}
const uint8 *PAKFile::getFileData(const char *file, uint32 *size) {
FileList *cur = (_fileList != 0) ? _fileList->findEntry(file) : 0;
FileList *cur = (_fileList != nullptr) ? _fileList->findEntry(file) : nullptr;
if (!cur)
return 0;
return nullptr;
if (size)
*size = cur->size;
@ -234,10 +234,10 @@ bool PAKFile::addFile(const char *name, uint8 *data, uint32 size) {
}
bool PAKFile::removeFile(const char *name) {
for (FileList *cur = _fileList, *last = 0; cur; last = cur, cur = cur->next) {
for (FileList *cur = _fileList, *last = nullptr; cur; last = cur, cur = cur->next) {
if (scumm_stricmp(cur->filename, name) == 0) {
FileList *next = cur->next;
cur->next = 0;
cur->next = nullptr;
delete cur;
if (last)
last->next = next;

View file

@ -4572,7 +4572,7 @@ static const ResourceProvider resourceProviders[] = {
{ kLoLCharacterDefs, kLoL, kPlatformDOS, kTalkieDemoVersion, EN_ANY, &kLoLCharacterDefsDOSCDDemoProvider },
{ kLoLCharacterDefs, kLoL, kPlatformDOS, kTalkieDemoVersion, FR_FRA, &kLoLCharacterDefsDOSCDDemoProvider },
{ kLoLCharacterDefs, kLoL, kPlatformDOS, kTalkieDemoVersion, DE_DEU, &kLoLCharacterDefsDOSCDDemoProvider },
{ kMaxResIDs, kKyra1, kPlatformDOS, kNoSpecial, UNK_LANG, NULL }
{ kMaxResIDs, kKyra1, kPlatformDOS, kNoSpecial, UNK_LANG, nullptr }
};
const ResourceProvider *obtainResourceProviders() {

View file

@ -1333,49 +1333,49 @@ void save_fight_segment(byte *&data, uint16 &totalSize) {
#define NUM_TEXT_ENTRIES 56
const char *englishTextStrings[NUM_TEXT_ENTRIES] = {
"Get", NULL, "Push", "Pull", "Operate", "Open", "Close", "Lock", "Unlock", "Use",
"Give", "Talk to", "Tell", "Buy", "Look", "Look at", "Look through", "Ask", NULL,
"Get", nullptr, "Push", "Pull", "Operate", "Open", "Close", "Lock", "Unlock", "Use",
"Give", "Talk to", "Tell", "Buy", "Look", "Look at", "Look through", "Ask", nullptr,
"Drink", "Status", "Go to", "Return", "Bribe", "Examine",
"Credits", "Restart game", "Save game", "Restore game", "Quit", "Fast Text\x8B",
"Slow Text\x8B", "Sound on", "Sound off", "(nothing)", " for ", " to ", " on ",
"and then", "finish", "Are you sure (y/n)?",
"You are carrying ", "nothing", "You have ", "groat", "groats",
NULL, "the ", "a ", "a ", "an ", "an ", "an ", "an ", NULL, NULL
nullptr, "the ", "a ", "a ", "an ", "an ", "an ", "an ", nullptr, nullptr
};
const char *italianTextStrings[NUM_TEXT_ENTRIES] = {
"Prendi", NULL, "Spingi", "Tira", "Aziona", "Apri", "Chiudi", "Blocca",
"Prendi", nullptr, "Spingi", "Tira", "Aziona", "Apri", "Chiudi", "Blocca",
"Sblocca", "Usa", "Dai", "Parla con", "Ordina a", "Compra", "Guarda", "Osserva",
"Guarda attraverso", "Chiedi", NULL, "Bevi", "Stato", "Vai a", "Ritorna",
"Guarda attraverso", "Chiedi", nullptr, "Bevi", "Stato", "Vai a", "Ritorna",
"Corrompi", "Esamina",
"Crediti", "Ricomincia", "Salva gioco", "Ripristina", "Abbandona", "Testo lento\x8B",
"Testo veloce\x8B", "Sonoro acceso", "Sonoro spento",
"(niente)", " per ", " a ", " su ",
"e poi", "finito", "Sei sicuro (s/n)?",
"Stai portando ", "niente", "Hai ", "soldo", "soldi",
NULL, "l' ", "la ", NULL, "le ", "i ", "il ", NULL, NULL, NULL
nullptr, "l' ", "la ", nullptr, "le ", "i ", "il ", nullptr, nullptr, nullptr
};
const char frenchUnlockStr[] = {'D', '\x7f', 'v', 'e', 'r', 'r', 'o', 'u', 'i', 'l', 'l', 'e', '\0'};
const char frenchCreditsStr[] = {'C', 'r', '\x7f', 'd', 'i', 't', 's', '\0'};
const char *frenchTextStrings[NUM_TEXT_ENTRIES] = {
"Prends", NULL, "Pousse", "Tire", "Actionne", "Ouvre", "Ferme", "Verrouille",
frenchUnlockStr, "Utilise", "Donne", "Parle \0x81", "Dis \x81", NULL,
"Regarde", "Observe", "Regarde par", "Demande \x81", NULL, "Bois", "Statut",
"Prends", nullptr, "Pousse", "Tire", "Actionne", "Ouvre", "Ferme", "Verrouille",
frenchUnlockStr, "Utilise", "Donne", "Parle \0x81", "Dis \x81", nullptr,
"Regarde", "Observe", "Regarde par", "Demande \x81", nullptr, "Bois", "Statut",
"Va \x81", "Reviens", "Corromps", "Examine",
frenchCreditsStr, "Recommencer", "Sauvegarder", "Restituer", "Quitter",
"Texte rapide\x8b", "Texte lent \x8b", "Avec son", "Sans son",
"(rien)", " avec ", " \x81 ", " sur ", "et puis", "fin",
"Vous \x83tes s\x89r (o/n)?",
"Vous avez ", "rien", "et vous avez ", "sou", "sous",
NULL, "les", "l'", "l'", "le", "le", "la", "la", NULL, NULL
nullptr, "les", "l'", "l'", "le", "le", "la", "la", nullptr, nullptr
};
const char *germanTextStrings[NUM_TEXT_ENTRIES] = {
"Nimm", NULL, "Schiebe", "Ziehe", "Bet\x8dtige", "\x90" "ffne", "Schlie\x92h" "e",
"Nimm", nullptr, "Schiebe", "Ziehe", "Bet\x8dtige", "\x90" "ffne", "Schlie\x92h" "e",
"Sperre", "Steck Schl\x8cssel in", "Benutze", "Gib", "Sprich mit", "Befehl an",
NULL, "Betrachte", "Betrachte", "Schau durch", "Verlange", NULL, "Trink",
nullptr, "Betrachte", "Betrachte", "Schau durch", "Verlange", nullptr, "Trink",
"Status", "Geh zu", "Zur\x8c" "ck", "Besteche", "Untersuche",
"Mitwirkende", "Spiel neu starten", "Spiel sichern", "Gesichertes Spiel laden",
"Abbrechen", "Schneller Text\x8b",
@ -1386,14 +1386,14 @@ const char *germanTextStrings[NUM_TEXT_ENTRIES] = {
};
const char *spanishTextStrings[NUM_TEXT_ENTRIES] = {
"Coge", NULL, "Empuja", "Tira de", "Opera", "Abre", "Cierra", "Atranca", "Desatranca", "Usa",
"Dale", "Habla con", "Dile a", "Compra", "Obsevar", "Observe", "Mirar por", "P\x97" "dele", NULL,
"Coge", nullptr, "Empuja", "Tira de", "Opera", "Abre", "Cierra", "Atranca", "Desatranca", "Usa",
"Dale", "Habla con", "Dile a", "Compra", "Obsevar", "Observe", "Mirar por", "P\x97" "dele", nullptr,
"Bebe", "Estado", "Ve a", "Regresa", "Sobornar", "Examinar",
"Cr\x7f" "ditos", "Reiniciar", "Salvar juego", "Recuperar jue", "Abandonar", "Texto r\x98pido\x8b",
"Texto lento \x8b", "Sonido activado ", "Sonido desactivado ", "(nada)", " con ", " a ", " con ",
"y luego", "eso es todo", "\x94" "Est\x98s seguro? (S/N)",
"Llevas ", "nada", "y tienes ", "moneda", "monedas",
"el ", "la ", "los ", "las ", "este ", "esta ", "estos ", "estas ", NULL, NULL
"el ", "la ", "los ", "las ", "este ", "esta ", "estos ", "estas ", nullptr, nullptr
};
void save_text_strings(byte *&data, uint16 &totalSize) {
@ -1410,7 +1410,7 @@ void save_text_strings(byte *&data, uint16 &totalSize) {
// Calculate the total needed space
totalSize = sizeof(uint16);
for (index = 0; index < NUM_TEXT_ENTRIES; ++index) {
if (textStrings[index] != NULL)
if (textStrings[index] != nullptr)
totalSize += strlen(textStrings[index]);
++totalSize;
}
@ -1421,7 +1421,7 @@ void save_text_strings(byte *&data, uint16 &totalSize) {
char *p = (char *) data + sizeof(uint16);
for (index = 0; index < NUM_TEXT_ENTRIES; ++index) {
if (textStrings[index] == NULL)
if (textStrings[index] == nullptr)
*p++ = '\0';
else {
strcpy(p, textStrings[index]);
@ -1485,7 +1485,7 @@ const DecoderEntry englishDecoders[] = {
{"111111111111101", '\xa7'}, {"1111111111111100", '/'}, {"1111111111111101", 'Q'},
{"11111111111111100", '\xa8'}, {"11111111111111101", '('}, {"111111111111111100", ')'},
{"111111111111111101", '\x99'}, {"11111111111111111", '\xa9'},
{NULL, '\0'}
{nullptr, '\0'}
};
const DecoderEntry konamiDecoders[] = {
@ -1531,7 +1531,7 @@ const DecoderEntry konamiDecoders[] = {
{ "11111111111111100", '\x99' }, { "111111111111111010", '(' }, { "111111111111111011", ')' },
{ "111111111111111100", '\xB2' }, { "111111111111111101", '\xDA' },
{ "11111111111111111", '\xEC' },
{ NULL, '\0' }
{ nullptr, '\0' }
};
const DecoderEntry italianDecoders[] = {
@ -1564,7 +1564,7 @@ const DecoderEntry italianDecoders[] = {
{"1111111111111100", (char) 0x4B}, {"1111111111111101", (char) 0x22}, {"111111111111111000", (char) 0x09},
{"111111111111111001", (char) 0x28}, {"11111111111111101", (char) 0x29}, {"111111111111111100", (char) 0x4A},
{"111111111111111101", (char) 0x59}, {"11111111111111111", (char) 0x78},
{NULL, '\0'}
{nullptr, '\0'}
};
const DecoderEntry frenchDecoders[] = {
@ -1609,7 +1609,7 @@ const DecoderEntry frenchDecoders[] = {
{"1111111111111011", (char) 0x28}, {"1111111111111100", (char) 0x29}, {"1111111111111101", (char) 0x5A},
{"11111111111111100", (char) 0x86}, {"11111111111111101", (char) 0x58}, {"11111111111111110", (char) 0x84},
{"11111111111111111", (char) 0xA2},
{NULL, '\0'}
{nullptr, '\0'}
};
const DecoderEntry germanDecoders[] = {
@ -1653,7 +1653,7 @@ const DecoderEntry germanDecoders[] = {
{"11111111111111010", (char) 0xBC}, {"11111111111111011", (char) 0x28}, {"111111111111111000", (char) 0x29},
{"111111111111111001", (char) 0x59}, {"11111111111111101", (char) 0xBB}, {"11111111111111110", (char) 0xBD},
{"11111111111111111", (char) 0xC0},
{NULL, '\0'}
{nullptr, '\0'}
};
const DecoderEntry spanishDecoders[] = {
@ -1688,7 +1688,7 @@ const DecoderEntry spanishDecoders[] = {
{"1111111111111100", (char) 0x5A}, {"1111111111111101", (char) 0x8C}, {"11111111111111100", (char) 0x28},
{"11111111111111101", (char) 0x29}, {"11111111111111110", (char) 0x4B}, {"111111111111111110", (char) 0x58},
{"111111111111111111", (char) 0x91},
{NULL, '\0'}
{nullptr, '\0'}
};
void save_string_decoder_data(byte *&data, uint16 &totalSize) {
@ -1702,7 +1702,7 @@ void save_string_decoder_data(byte *&data, uint16 &totalSize) {
totalSize = 1;
const DecoderEntry *pSrc = list;
while (pSrc->sequence != NULL) {
while (pSrc->sequence != nullptr) {
totalSize += strlen(pSrc->sequence) + 2;
++pSrc;
}
@ -1711,7 +1711,7 @@ void save_string_decoder_data(byte *&data, uint16 &totalSize) {
char *pDest = (char *)data;
pSrc = list;
while (pSrc->sequence != NULL) {
while (pSrc->sequence != nullptr) {
*pDest++ = pSrc->character;
strcpy(pDest, pSrc->sequence);
pDest += strlen(pSrc->sequence) + 1;
@ -1872,7 +1872,7 @@ void getEntry(uint8 entryIndex, uint16 &resourceId, byte *&data, uint16 &size) {
break;
default:
data = NULL;
data = nullptr;
size = 0;
resourceId = 0xffff;
break;
@ -1955,7 +1955,7 @@ void createFile(const char *outFilename) {
resourceFlag = true;
for (int resIndex=0; resIndex < 0xBE; ++resIndex) {
resourceData = NULL;
resourceData = nullptr;
// Get next data entry
if (resourceFlag)
@ -2054,7 +2054,7 @@ bool validate_executable() {
int main(int argc, char *argv[]) {
const char /**inFilename,*/ *outFilename = 0;
const char /**inFilename,*/ *outFilename = nullptr;
if (argc == 1) {
printf("Format: %s output_filename [lureExecutable ..]\n", argv[0]);

View file

@ -380,7 +380,7 @@ void read_action_sequence(byte *&data, uint16 &totalSize) {
for (roomIndex = 0; roomIndex < RANDOM_ROOM_NUM_ENTRIES; ++roomIndex) {
randomActions[roomIndex].offset = lureExe.readWord();
randomActions[roomIndex].numEntries = 0;
randomActions[roomIndex].entries = NULL;
randomActions[roomIndex].entries = nullptr;
}
// Next get the set of offsetes for the start of each sequence
@ -540,7 +540,7 @@ void read_action_sequence(byte *&data, uint16 &totalSize) {
// Free up the random room action array
for (roomIndex = 0; roomIndex < 1; ++roomIndex) {
if (randomActions[roomIndex].entries != NULL)
if (randomActions[roomIndex].entries != nullptr)
delete[] randomActions[roomIndex].entries;
}
delete[] randomActions;

View file

@ -36,12 +36,12 @@
bool File::open(const char *filename, AccessMode mode) {
f = fopen(filename, (mode == kFileReadMode) ? "rb" : "wb");
return (f != NULL);
return (f != nullptr);
}
void File::close() {
fclose(f);
f = NULL;
f = nullptr;
}
int File::seek(int32 offset, int whence) {

View file

@ -81,7 +81,7 @@ byte *getData(uint32 offset) {
}
const char *getStringP(uint32 offset) {
return offset != 0 ? (const char*)getData(offset) : NULL;
return offset != 0 ? (const char*)getData(offset) : nullptr;
}
uint32 calcHash(const char *value) {

View file

@ -228,7 +228,7 @@ bool md5_file(const char *name, uint8 digest[16], uint32 length) {
FILE *f;
f = fopen(name, "rb");
if (f == NULL) {
if (f == nullptr) {
printf("md5_file couldn't open '%s'\n", name);
return false;
}

View file

@ -36,28 +36,28 @@ CMakeProvider::CMakeProvider(StringList &global_warnings, std::map<std::string,
const CMakeProvider::Library *CMakeProvider::getLibraryFromFeature(const char *feature, bool useSDL2) const {
static const Library s_libraries[] = {
{ "sdl", "sdl", kSDLVersion1, "FindSDL", "SDL", "SDL_INCLUDE_DIR", "SDL_LIBRARY", 0 },
{ "sdl", "sdl2", kSDLVersion2, 0, "SDL2", 0, "SDL2_LIBRARIES", 0 },
{ "freetype", "freetype2", kSDLVersionAny, "FindFreetype", "Freetype", "FREETYPE_INCLUDE_DIRS", "FREETYPE_LIBRARIES", 0 },
{ "libz", "zlib", kSDLVersionAny, "FindZLIB", "ZLIB", "ZLIB_INCLUDE_DIRS", "ZLIB_LIBRARIES", 0 },
{ "png", "libpng", kSDLVersionAny, "FindPNG", "PNG", "PNG_INCLUDE_DIRS", "PNG_LIBRARIES", 0 },
{ "jpeg", "libjpeg", kSDLVersionAny, "FindJPEG", "JPEG", "JPEG_INCLUDE_DIRS", "JPEG_LIBRARIES", 0 },
{ "mpeg2", "libmpeg2", kSDLVersionAny, "FindMPEG2", "MPEG2", "MPEG2_INCLUDE_DIRS", "MPEG2_mpeg2_LIBRARY", 0 },
{ "flac", "flac", kSDLVersionAny, 0, 0, 0, 0, "FLAC" },
{ "mad", "mad", kSDLVersionAny, 0, 0, 0, 0, "mad" },
{ "ogg", "ogg", kSDLVersionAny, 0, 0, 0, 0, "ogg" },
{ "vorbis", "vorbisfile vorbis", kSDLVersionAny, 0, 0, 0, 0, "vorbisfile vorbis" },
{ "tremor", "vorbisidec", kSDLVersionAny, 0, 0, 0, 0, "vorbisidec" },
{ "theora", "theoradec", kSDLVersionAny, 0, 0, 0, 0, "theoradec" },
{ "fluidsynth", "fluidsynth", kSDLVersionAny, 0, 0, 0, 0, "fluidsynth" },
{ "faad", "faad2", kSDLVersionAny, 0, 0, 0, 0, "faad" },
{ "fribidi", "fribidi", kSDLVersionAny, 0, 0, 0, 0, "fribidi" },
{ "discord", "discord", kSDLVersionAny, 0, 0, 0, 0, "discord-rpc"},
{ "opengl", 0, kSDLVersionAny, "FindOpenGL", "OpenGL", "OPENGL_INCLUDE_DIR", "OPENGL_gl_LIBRARY", 0 },
{ "glew", "glew", kSDLVersionAny, "FindGLEW", "GLEW", "GLEW_INCLUDE_DIR", "GLEW_LIBRARIES", 0 },
{ "libcurl", "libcurl", kSDLVersionAny, "FindCURL", "CURL", "CURL_INCLUDE_DIRS", "CURL_LIBRARIES", 0 },
{ "sdlnet", 0, kSDLVersion1, "FindSDL_net", "SDL_net", "SDL_NET_INCLUDE_DIRS", "SDL_NET_LIBRARIES", 0 },
{ "sdlnet", "SDL2_net", kSDLVersion2, 0, 0, 0, 0, "SDL2_net" }
{ "sdl", "sdl", kSDLVersion1, "FindSDL", "SDL", "SDL_INCLUDE_DIR", "SDL_LIBRARY", nullptr },
{ "sdl", "sdl2", kSDLVersion2, nullptr, "SDL2", nullptr, "SDL2_LIBRARIES", nullptr },
{ "freetype", "freetype2", kSDLVersionAny, "FindFreetype", "Freetype", "FREETYPE_INCLUDE_DIRS", "FREETYPE_LIBRARIES", nullptr },
{ "libz", "zlib", kSDLVersionAny, "FindZLIB", "ZLIB", "ZLIB_INCLUDE_DIRS", "ZLIB_LIBRARIES", nullptr },
{ "png", "libpng", kSDLVersionAny, "FindPNG", "PNG", "PNG_INCLUDE_DIRS", "PNG_LIBRARIES", nullptr },
{ "jpeg", "libjpeg", kSDLVersionAny, "FindJPEG", "JPEG", "JPEG_INCLUDE_DIRS", "JPEG_LIBRARIES", nullptr },
{ "mpeg2", "libmpeg2", kSDLVersionAny, "FindMPEG2", "MPEG2", "MPEG2_INCLUDE_DIRS", "MPEG2_mpeg2_LIBRARY", nullptr },
{ "flac", "flac", kSDLVersionAny, nullptr, nullptr, nullptr, nullptr, "FLAC" },
{ "mad", "mad", kSDLVersionAny, nullptr, nullptr, nullptr, nullptr, "mad" },
{ "ogg", "ogg", kSDLVersionAny, nullptr, nullptr, nullptr, nullptr, "ogg" },
{ "vorbis", "vorbisfile vorbis", kSDLVersionAny, nullptr, nullptr, nullptr, nullptr, "vorbisfile vorbis" },
{ "tremor", "vorbisidec", kSDLVersionAny, nullptr, nullptr, nullptr, nullptr, "vorbisidec" },
{ "theora", "theoradec", kSDLVersionAny, nullptr, nullptr, nullptr, nullptr, "theoradec" },
{ "fluidsynth", "fluidsynth", kSDLVersionAny, nullptr, nullptr, nullptr, nullptr, "fluidsynth" },
{ "faad", "faad2", kSDLVersionAny, nullptr, nullptr, nullptr, nullptr, "faad" },
{ "fribidi", "fribidi", kSDLVersionAny, nullptr, nullptr, nullptr, nullptr, "fribidi" },
{ "discord", "discord", kSDLVersionAny, nullptr, nullptr, nullptr, nullptr, "discord-rpc"},
{ "opengl", nullptr, kSDLVersionAny, "FindOpenGL", "OpenGL", "OPENGL_INCLUDE_DIR", "OPENGL_gl_LIBRARY", nullptr },
{ "glew", "glew", kSDLVersionAny, "FindGLEW", "GLEW", "GLEW_INCLUDE_DIR", "GLEW_LIBRARIES", nullptr },
{ "libcurl", "libcurl", kSDLVersionAny, "FindCURL", "CURL", "CURL_INCLUDE_DIRS", "CURL_LIBRARIES", nullptr },
{ "sdlnet", nullptr, kSDLVersion1, "FindSDL_net", "SDL_net", "SDL_NET_INCLUDE_DIRS", "SDL_NET_LIBRARIES", nullptr },
{ "sdlnet", "SDL2_net", kSDLVersion2, nullptr, nullptr, nullptr, nullptr, "SDL2_net" }
};
for (unsigned int i = 0; i < sizeof(s_libraries) / sizeof(s_libraries[0]); i++) {
@ -69,7 +69,7 @@ const CMakeProvider::Library *CMakeProvider::getLibraryFromFeature(const char *f
}
}
return 0;
return nullptr;
}
void CMakeProvider::createWorkspace(const BuildSetup &setup) {

View file

@ -108,7 +108,7 @@ std::map<std::string, bool> isEngineEnabled;
int main(int argc, char *argv[]) {
#ifndef USE_WIN32_API
// Initialize random number generator for UUID creation
std::srand((unsigned int)std::time(0));
std::srand((unsigned int)std::time(nullptr));
#endif
if (argc < 2) {
@ -135,7 +135,7 @@ int main(int argc, char *argv[]) {
setup.features = getAllFeatures();
ProjectType projectType = kProjectNone;
const MSVCVersion *msvc = NULL;
const MSVCVersion *msvc = nullptr;
int msvcVersion = 0;
// Parse command line arguments
@ -451,7 +451,7 @@ int main(int argc, char *argv[]) {
StringList globalWarnings;
std::map<std::string, StringList> projectWarnings;
CreateProjectTool::ProjectProvider *provider = NULL;
CreateProjectTool::ProjectProvider *provider = nullptr;
switch (projectType) {
default:
@ -1239,7 +1239,7 @@ const MSVCVersion *getMSVCVersion(int version) {
return &s_msvc[i];
}
return NULL;
return nullptr;
}
int getInstalledMSVC() {
@ -1248,9 +1248,9 @@ int getInstalledMSVC() {
// Use the Visual Studio Installer to get the latest version
const char *vsWhere = "\"\"%PROGRAMFILES(X86)%\\Microsoft Visual Studio\\Installer\\vswhere.exe\" -latest -legacy -property installationVersion\"";
FILE *pipe = _popen(vsWhere, "rt");
if (pipe != NULL) {
if (pipe != nullptr) {
char version[50];
if (fgets(version, 50, pipe) != NULL) {
if (fgets(version, 50, pipe) != nullptr) {
latest = atoi(version);
}
_pclose(pipe);
@ -1260,12 +1260,12 @@ int getInstalledMSVC() {
if (latest == 0) {
HKEY key;
LONG err = RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7"), 0, KEY_QUERY_VALUE | KEY_WOW64_32KEY, &key);
if (err == ERROR_SUCCESS && key != NULL) {
if (err == ERROR_SUCCESS && key != nullptr) {
const MSVCList msvc = getAllMSVCVersions();
for (MSVCList::const_reverse_iterator i = msvc.rbegin(); i != msvc.rend(); ++i) {
std::ostringstream version;
version << i->version << ".0";
err = RegQueryValueExA(key, version.str().c_str(), NULL, NULL, NULL, NULL);
err = RegQueryValueExA(key, version.str().c_str(), nullptr, nullptr, nullptr, nullptr);
if (err == ERROR_SUCCESS) {
latest = i->version;
break;
@ -1460,7 +1460,7 @@ FileList listDirectory(const std::string &dir) {
void createDirectory(const std::string &dir) {
#if defined(_WIN32) || defined(WIN32)
if (!CreateDirectoryA(dir.c_str(), NULL)) {
if (!CreateDirectoryA(dir.c_str(), nullptr)) {
if (GetLastError() != ERROR_ALREADY_EXISTS) {
error("Could not create folder \"" + dir + "\"");
}
@ -1496,7 +1496,7 @@ FileNode *scanFiles(const std::string &dir, const StringList &includeList, const
FileList files = listDirectory(dir);
if (files.empty())
return 0;
return nullptr;
FileNode *result = new FileNode(dir);
assert(result);
@ -1532,7 +1532,7 @@ FileNode *scanFiles(const std::string &dir, const StringList &includeList, const
if (result->children.empty()) {
delete result;
return 0;
return nullptr;
} else {
result->children.sort(compareNodes);
return result;

View file

@ -55,32 +55,32 @@ MSVCProvider::MSVCProvider(StringList &global_warnings, std::map<std::string, St
std::string MSVCProvider::getLibraryFromFeature(const char *feature, const BuildSetup &setup, bool isRelease) const {
static const MSVCLibrary s_libraries[] = {
// Libraries
{ "sdl", "SDL.lib", "SDLd.lib", "winmm.lib imm32.lib version.lib setupapi.lib", 0 },
{ "sdl2", "SDL2.lib", "SDL2d.lib", "winmm.lib imm32.lib version.lib setupapi.lib", 0 },
{ "libz", "zlib.lib", "zlibd.lib", 0, 0 },
{ "mad", "mad.lib", 0, 0, "libmad.lib" },
{ "fribidi", "fribidi.lib", 0, 0, 0 },
{ "ogg", "ogg.lib", 0, 0, "libogg_static.lib" },
{ "vorbis", "vorbis.lib vorbisfile.lib", 0, 0, "libvorbisfile_static.lib libvorbis_static.lib" },
{ "flac", "FLAC.lib", 0, 0, "libFLAC_static.lib win_utf8_io_static.lib" },
{ "png", "libpng16.lib", "libpng16d.lib", 0, 0 },
{ "gif", "gif.lib", 0, 0, 0 },
{ "faad", "faad.lib", 0, 0, "libfaad.lib" },
{ "mpeg2", "mpeg2.lib", 0, 0, "libmpeg2.lib" },
{ "theora", "theora.lib", 0, 0, "libtheora_static.lib" },
{ "freetype", "freetype.lib", "freetyped.lib", 0, 0 },
{ "jpeg", "jpeg.lib", 0, 0, "jpeg-static.lib" },
{"fluidsynth", "fluidsynth.lib", 0, 0, "libfluidsynth.lib" },
{ "fluidlite", "fluidlite.lib", 0, 0, 0 },
{ "libcurl", "libcurl.lib", "libcurl-d.lib", "ws2_32.lib wldap32.lib crypt32.lib normaliz.lib", 0 },
{ "sdlnet", "SDL_net.lib", 0, "iphlpapi.lib", 0 },
{ "sdl2net", "SDL2_net.lib", 0, "iphlpapi.lib", "SDL_net.lib" },
{ "discord", "discord-rpc.lib", 0, 0, 0 },
{ "glew", "glew32.lib", "glew32d.lib", 0, 0 },
{ "sdl", "SDL.lib", "SDLd.lib", "winmm.lib imm32.lib version.lib setupapi.lib", nullptr },
{ "sdl2", "SDL2.lib", "SDL2d.lib", "winmm.lib imm32.lib version.lib setupapi.lib", nullptr },
{ "libz", "zlib.lib", "zlibd.lib", nullptr, nullptr },
{ "mad", "mad.lib", nullptr, nullptr, "libmad.lib" },
{ "fribidi", "fribidi.lib", nullptr, nullptr, nullptr },
{ "ogg", "ogg.lib", nullptr, nullptr, "libogg_static.lib" },
{ "vorbis", "vorbis.lib vorbisfile.lib", nullptr, nullptr, "libvorbisfile_static.lib libvorbis_static.lib" },
{ "flac", "FLAC.lib", nullptr, nullptr, "libFLAC_static.lib win_utf8_io_static.lib" },
{ "png", "libpng16.lib", "libpng16d.lib", nullptr, nullptr },
{ "gif", "gif.lib", nullptr, nullptr, nullptr },
{ "faad", "faad.lib", nullptr, nullptr, "libfaad.lib" },
{ "mpeg2", "mpeg2.lib", nullptr, nullptr, "libmpeg2.lib" },
{ "theora", "theora.lib", nullptr, nullptr, "libtheora_static.lib" },
{ "freetype", "freetype.lib", "freetyped.lib", nullptr, nullptr },
{ "jpeg", "jpeg.lib", nullptr, nullptr, "jpeg-static.lib" },
{"fluidsynth", "fluidsynth.lib", nullptr, nullptr, "libfluidsynth.lib" },
{ "fluidlite", "fluidlite.lib", nullptr, nullptr, nullptr },
{ "libcurl", "libcurl.lib", "libcurl-d.lib", "ws2_32.lib wldap32.lib crypt32.lib normaliz.lib", nullptr },
{ "sdlnet", "SDL_net.lib", nullptr, "iphlpapi.lib", nullptr },
{ "sdl2net", "SDL2_net.lib", nullptr, "iphlpapi.lib", "SDL_net.lib" },
{ "discord", "discord-rpc.lib", nullptr, nullptr, nullptr },
{ "glew", "glew32.lib", "glew32d.lib", nullptr, nullptr },
// Feature flags with library dependencies
{ "updates", "winsparkle.lib", 0, 0, 0 },
{ "tts", 0, 0, "sapi.lib", 0 },
{ "opengl", 0, 0, "opengl32.lib", 0 }
{ "updates", "winsparkle.lib", nullptr, nullptr, nullptr },
{ "tts", nullptr, nullptr, "sapi.lib", nullptr },
{ "opengl", nullptr, nullptr, "opengl32.lib", nullptr }
};
// HACK for switching SDL_net to SDL2_net
@ -89,7 +89,7 @@ std::string MSVCProvider::getLibraryFromFeature(const char *feature, const Build
feature = sdl2net;
}
const MSVCLibrary *library = 0;
const MSVCLibrary *library = nullptr;
for (unsigned int i = 0; i < sizeof(s_libraries) / sizeof(s_libraries[0]); i++) {
if (std::strcmp(feature, s_libraries[i].feature) == 0) {
library = &s_libraries[i];

View file

@ -220,7 +220,7 @@ XcodeProvider::Group *XcodeProvider::Group::getChildGroup(const std::string &nam
}
XcodeProvider::Group *XcodeProvider::touchGroupsForPath(const std::string &path) {
if (_rootSourceGroup == NULL) {
if (_rootSourceGroup == nullptr) {
assert(path == _projectRoot);
_rootSourceGroup = new Group(this, "Sources", path, path);
_groups.add(_rootSourceGroup);
@ -272,7 +272,7 @@ void XcodeProvider::addBuildFile(const std::string &id, const std::string &name,
XcodeProvider::XcodeProvider(StringList &global_warnings, std::map<std::string, StringList> &project_warnings, const int version)
: ProjectProvider(global_warnings, project_warnings, version) {
_rootSourceGroup = NULL;
_rootSourceGroup = nullptr;
}
void XcodeProvider::addResourceFiles(const BuildSetup &setup, StringList &includeList, StringList &excludeList) {

View file

@ -13,7 +13,7 @@
const char *lang[] = {
"en",
"it",
NULL
nullptr
};
void writeDatafile(File& outputFile, int fileNumber, const char* language, int part) {

View file

@ -2,12 +2,12 @@
bool File::open(const char *filename, AccessMode mode) {
f = fopen(filename, (mode == kFileReadMode) ? "rb" : "wb");
return (f != NULL);
return (f != nullptr);
}
void File::close() {
fclose(f);
f = NULL;
f = nullptr;
}
int File::seek(int32 offset, int whence) {

View file

@ -5,7 +5,7 @@
#include "po_parser.h"
PoMessageList::PoMessageList() : _list(NULL), _size(0), _allocated(0) {
PoMessageList::PoMessageList() : _list(nullptr), _size(0), _allocated(0) {
}
PoMessageList::~PoMessageList() {
@ -15,11 +15,11 @@ PoMessageList::~PoMessageList() {
}
int PoMessageList::compareString(const char* left, const char* right) {
if (left == NULL && right == NULL)
if (left == nullptr && right == nullptr)
return 0;
if (left == NULL)
if (left == nullptr)
return -1;
if (right == NULL)
if (right == nullptr)
return 1;
return strcmp(left, right);
}
@ -32,7 +32,7 @@ int PoMessageList::compareMessage(const char *msgLeft, const char *contextLeft,
}
void PoMessageList::insert(const char *translation, const char *msg, const char *context) {
if (msg == NULL || *msg == '\0' || translation == NULL || *translation == '\0')
if (msg == nullptr || *msg == '\0' || translation == nullptr || *translation == '\0')
return;
// binary-search for the insertion index
@ -68,8 +68,8 @@ void PoMessageList::insert(const char *translation, const char *msg, const char
}
const char *PoMessageList::findTranslation(const char *msg, const char *context) {
if (msg == NULL || *msg == '\0')
return NULL;
if (msg == nullptr || *msg == '\0')
return nullptr;
// binary-search for the message
int leftIndex = 0;
@ -84,13 +84,13 @@ const char *PoMessageList::findTranslation(const char *msg, const char *context)
else
leftIndex = midIndex + 1;
}
return NULL;
return nullptr;
}
PoMessageList *parsePoFile(const char *file) {
FILE *inFile = fopen(file, "r");
if (!inFile)
return NULL;
return nullptr;
char msgidBuf[1024], msgctxtBuf[1024], msgstrBuf[1024];
char line[1024], *currentBuf = msgstrBuf;
@ -198,8 +198,8 @@ char *parseLine(const char *line, const char *field) {
// It is used to parse the header of the po files to find the language name
// and the charset.
const char *str = strstr(line, field);
if (str == NULL)
return NULL;
if (str == nullptr)
return nullptr;
str += strlen(field);
// Skip spaces
while (*str != '\0' && isspace(*str)) {
@ -211,7 +211,7 @@ char *parseLine(const char *line, const char *field) {
++len;
}
if (len == 0)
return NULL;
return nullptr;
// Create result string
char *result = new char[len + 1];
strncpy(result, str, len);

View file

@ -33,7 +33,7 @@ int main(int argc, char *argv[]) {
const char *dat_name = "teenagent.dat";
FILE *fout = fopen(dat_name, "wb");
if (fout == NULL) {
if (fout == nullptr) {
perror("opening output file");
exit(1);
}

View file

@ -43,7 +43,7 @@ static size_t adjustChunkSize(size_t chunkSize) {
MemoryPool::MemoryPool(size_t chunkSize)
: _chunkSize(adjustChunkSize(chunkSize)) {
_next = NULL;
_next = nullptr;
_chunksPerPage = INITIAL_CHUNKS_PER_PAGE;
}
@ -154,7 +154,7 @@ void MemoryPool::freeUnusedPages() {
::free(_pages[i].start);
++freedPagesCount;
_pages[i].start = NULL;
_pages[i].start = nullptr;
}
}
@ -163,7 +163,7 @@ void MemoryPool::freeUnusedPages() {
// Remove all now unused pages
size_t newSize = 0;
for (size_t i = 0; i < _pages.size(); ++i) {
if (_pages[i].start != NULL) {
if (_pages[i].start != nullptr) {
if (newSize != i)
_pages[newSize] = _pages[i];
++newSize;

View file

@ -31,7 +31,7 @@
namespace Common {
PEResources::PEResources() {
_exe = 0;
_exe = nullptr;
}
PEResources::~PEResources() {
@ -41,7 +41,7 @@ PEResources::~PEResources() {
void PEResources::clear() {
_sections.clear();
_resources.clear();
delete _exe; _exe = 0;
delete _exe; _exe = nullptr;
}
bool PEResources::loadFromEXE(File *stream) {
@ -207,7 +207,7 @@ File *PEResources::getResource(const WinResourceID &type, const WinResourceID &i
Array<WinResourceID> langList = getLangList(type, id);
if (langList.empty())
return 0;
return nullptr;
const Resource &resource = _resources[type][id][langList[0]];
byte *data = (byte *)malloc(resource.size);
@ -221,17 +221,17 @@ File *PEResources::getResource(const WinResourceID &type, const WinResourceID &i
File *PEResources::getResource(const WinResourceID &type, const WinResourceID &id, const WinResourceID &lang) {
if (!_exe || !_resources.contains(type))
return 0;
return nullptr;
const IDMap &idMap = _resources[type];
if (!idMap.contains(id))
return 0;
return nullptr;
const LangMap &langMap = idMap[id];
if (!langMap.contains(lang))
return 0;
return nullptr;
const Resource &resource = langMap[lang];
byte *data = (byte *)malloc(resource.size);

View file

@ -83,7 +83,7 @@ bool inflateZlibHeaderless(byte *dst, uint dstLen, const byte *src, uint srcLen,
return false;
// Set the dictionary, if provided
if (dict != 0) {
if (dict != nullptr) {
err = inflateSetDictionary(&stream, const_cast<byte *>(dict), dictLen);
if (err != Z_OK)
return false;
@ -180,7 +180,7 @@ protected:
public:
GZipReadStream(SeekableReadStream *w, uint32 knownSize = 0) : _wrapped(w), _stream() {
assert(w != 0);
assert(w != nullptr);
// Verify file header is correct
w->seek(0, SEEK_SET);
@ -349,7 +349,7 @@ protected:
public:
GZipWriteStream(WriteStream *w) : _wrapped(w), _stream(), _pos(0) {
assert(w != 0);
assert(w != nullptr);
// Adding 16 to windowBits indicates to zlib that it is supposed to
// write gzip headers. This feature was added in zlib 1.2.0.4,
@ -366,7 +366,7 @@ public:
_stream.next_out = _buf;
_stream.avail_out = BUFSIZE;
_stream.avail_in = 0;
_stream.next_in = 0;
_stream.next_in = nullptr;
}
~GZipWriteStream() {

View file

@ -72,7 +72,7 @@ void writeUint32BE(FILE *fp, uint32 value) {
int stringSize(const char *string) {
// Each string is preceded by its size coded on 2 bytes
if (string == NULL)
if (string == nullptr)
return 2;
int len = strlen(string) + 1;
return 2 + len;
@ -83,7 +83,7 @@ int stringSize(const char *string) {
void writeString(FILE *fp, const char *string) {
// Each string is preceded by its size coded on 2 bytes
if (string == NULL) {
if (string == nullptr) {
writeUint16BE(fp, 0);
return;
}
@ -109,7 +109,7 @@ int main(int argc, char *argv[]) {
int len = strlen(argv[i]);
if (scumm_stricmp(argv[i] + len - 2, "po") == 0) {
PoMessageEntryList *po = parsePoFile(argv[i], messageIds);
if (po != NULL) {
if (po != nullptr) {
translations.push_back(po);
++numLangs;
}

View file

@ -29,7 +29,7 @@
#include "po_parser.h"
PoMessageList::PoMessageList() : _messages(NULL), _size(0), _allocated(0) {
PoMessageList::PoMessageList() : _messages(nullptr), _size(0), _allocated(0) {
}
PoMessageList::~PoMessageList() {
@ -39,7 +39,7 @@ PoMessageList::~PoMessageList() {
}
void PoMessageList::insert(const char *msg) {
if (msg == NULL || *msg == '\0')
if (msg == nullptr || *msg == '\0')
return;
// binary-search for the insertion index
@ -76,7 +76,7 @@ void PoMessageList::insert(const char *msg) {
}
int PoMessageList::findIndex(const char *msg) {
if (msg == NULL || *msg == '\0')
if (msg == nullptr || *msg == '\0')
return -1;
// binary-search for the message
@ -103,13 +103,13 @@ int PoMessageList::size() const {
const char *PoMessageList::operator[](int index) const {
if (index < 0 || index >= _size)
return NULL;
return nullptr;
return _messages[index];
}
PoMessageEntryList::PoMessageEntryList(const char *lang) :
_lang(NULL), _langName(NULL), _langNameAlt(NULL), _useUTF8(true),
_list(NULL), _size(0), _allocated(0)
_lang(nullptr), _langName(nullptr), _langNameAlt(nullptr), _useUTF8(true),
_list(nullptr), _size(0), _allocated(0)
{
_lang = new char[1 + strlen(lang)];
strcpy(_lang, lang);
@ -132,12 +132,12 @@ void PoMessageEntryList::addMessageEntry(const char *translation, const char *me
// This is the header.
// We get the charset and the language name from the translation string
char *str = parseLine(translation, "X-Language-name:");
if (str != NULL) {
if (str != nullptr) {
delete[] _langName;
_langName = str;
}
str = parseLine(translation, "Language:");
if (str != NULL) {
if (str != nullptr) {
delete[] _langNameAlt;
_langNameAlt = str;
}
@ -155,12 +155,12 @@ void PoMessageEntryList::addMessageEntry(const char *translation, const char *me
int midIndex = (leftIndex + rightIndex) / 2;
int compareResult = strcmp(message, _list[midIndex]->msgid);
if (compareResult == 0) {
if (context == NULL) {
if (_list[midIndex]->msgctxt == NULL)
if (context == nullptr) {
if (_list[midIndex]->msgctxt == nullptr)
return;
compareResult = -1;
} else {
if (_list[midIndex]->msgctxt == NULL)
if (_list[midIndex]->msgctxt == nullptr)
compareResult = 1;
else {
compareResult = strcmp(context, _list[midIndex]->msgctxt);
@ -180,14 +180,14 @@ void PoMessageEntryList::addMessageEntry(const char *translation, const char *me
// context if it is not present for a specific context, we can optimize the file
// size, memory used at run-time and performances (less strings to read from the file
// and less strings to look for) by avoiding duplicate.
if (context != NULL && *context != '\0') {
if (context != nullptr && *context != '\0') {
// Check if we have the same translation for no context
int contextIndex = leftIndex - 1;
while (contextIndex >= 0 && strcmp (message, _list[contextIndex]->msgid) == 0) {
--contextIndex;
}
++contextIndex;
if (contextIndex < leftIndex && _list[contextIndex]->msgctxt == NULL && strcmp(translation, _list[contextIndex]->msgstr) == 0)
if (contextIndex < leftIndex && _list[contextIndex]->msgctxt == nullptr && strcmp(translation, _list[contextIndex]->msgstr) == 0)
return;
}
@ -208,7 +208,7 @@ void PoMessageEntryList::addMessageEntry(const char *translation, const char *me
_list[leftIndex] = new PoMessageEntry(translation, message, context);
++_size;
if (context == NULL || *context == '\0') {
if (context == nullptr || *context == '\0') {
// Remove identical translations for a specific context (see comment above)
int contextIndex = leftIndex + 1;
int removed = 0;
@ -250,7 +250,7 @@ int PoMessageEntryList::size() const {
const PoMessageEntry *PoMessageEntryList::entry(int index) const {
if (index < 0 || index >= _size)
return NULL;
return nullptr;
return _list[index];
}
@ -258,7 +258,7 @@ const PoMessageEntry *PoMessageEntryList::entry(int index) const {
PoMessageEntryList *parsePoFile(const char *file, PoMessageList& messages) {
FILE *inFile = fopen(file, "r");
if (!inFile)
return NULL;
return nullptr;
char msgidBuf[2048], msgctxtBuf[2048], msgstrBuf[2048];
char line[2048], *currentBuf = msgstrBuf;
@ -382,8 +382,8 @@ char *parseLine(const char *line, const char *field) {
// It is used to parse the header of the po files to find the language name
// and the charset.
const char *str = strstr(line, field);
if (str == NULL)
return NULL;
if (str == nullptr)
return nullptr;
str += strlen(field);
// Skip spaces
while (*str != '\0' && isspace(*str)) {
@ -395,7 +395,7 @@ char *parseLine(const char *line, const char *field) {
++len;
}
if (len == 0)
return NULL;
return nullptr;
// Create result string
char *result = new char[len + 1];
strncpy(result, str, len);

View file

@ -43,7 +43,7 @@ static size_t adjustChunkSize(size_t chunkSize) {
MemoryPool::MemoryPool(size_t chunkSize)
: _chunkSize(adjustChunkSize(chunkSize)) {
_next = NULL;
_next = nullptr;
_chunksPerPage = INITIAL_CHUNKS_PER_PAGE;
}
@ -154,7 +154,7 @@ void MemoryPool::freeUnusedPages() {
::free(_pages[i].start);
++freedPagesCount;
_pages[i].start = NULL;
_pages[i].start = nullptr;
}
}
@ -163,7 +163,7 @@ void MemoryPool::freeUnusedPages() {
// Remove all now unused pages
size_t newSize = 0;
for (size_t i = 0; i < _pages.size(); ++i) {
if (_pages[i].start != NULL) {
if (_pages[i].start != nullptr) {
if (newSize != i)
_pages[newSize] = _pages[i];
++newSize;

View file

@ -44,11 +44,11 @@ private:
public:
bool open(const char *filename, AccessMode mode = kFileReadMode) {
f = fopen(filename, (mode == kFileReadMode) ? "rb" : "wb");
return (f != NULL);
return (f != nullptr);
}
void close() {
fclose(f);
f = NULL;
f = nullptr;
}
int seek(int32 offset, int whence = SEEK_SET) {
return fseek(f, offset, whence);

View file

@ -816,7 +816,7 @@ static const unsigned char spanishCharsetDataV2[] = {
0x08, 0x0c, 0x0e, 0xff, 0xff, 0x0e, 0x0c, 0x08,
};
unsigned char *specialCharsetData = NULL;
unsigned char *specialCharsetData = nullptr;
int numSpecialChars = 0;
void compressCharset(const unsigned char *data, const char *var, const char *name) {
@ -884,7 +884,7 @@ int main(int /*argc*/, char ** /*argv*/) {
printf("};\n");
free(specialCharsetData);
specialCharsetData = NULL;
specialCharsetData = nullptr;
return 0;
}

View file

@ -92,7 +92,7 @@ static const StringMap platformMap[] = {
{ "All?", "kPlatformUnknown" },
{ "All", "kPlatformUnknown" },
{ 0, "kPlatformUnknown" }
{ nullptr, "kPlatformUnknown" }
};
static const StringMap langMap[] = {
@ -119,7 +119,7 @@ static const StringMap langMap[] = {
{ "All", "UNK_LANG" },
{ "All?", "UNK_LANG" },
{ 0, "UNK_LANG" }
{ nullptr, "UNK_LANG" }
};
static const char *php_header =
@ -166,13 +166,13 @@ static void parseEntry(Entry *entry, char *line) {
/* Split at the tabs */
entry->md5 = strtok(line, "\t\n\r");
entry->size = strtok(NULL, "\t\n\r");
entry->language = strtok(NULL, "\t\n\r");
entry->platform = strtok(NULL, "\t\n\r");
entry->variant = strtok(NULL, "\t\n\r");
entry->extra = strtok(NULL, "\t\n\r");
entry->desc = strtok(NULL, "\t\n\r");
entry->infoSource = strtok(NULL, "\t\n\r");
entry->size = strtok(nullptr, "\t\n\r");
entry->language = strtok(nullptr, "\t\n\r");
entry->platform = strtok(nullptr, "\t\n\r");
entry->variant = strtok(nullptr, "\t\n\r");
entry->extra = strtok(nullptr, "\t\n\r");
entry->desc = strtok(nullptr, "\t\n\r");
entry->infoSource = strtok(nullptr, "\t\n\r");
}
static int isEmptyLine(const char *line) {

View file

@ -25,7 +25,7 @@
TextFile::TextFile(const char *name) {
FILE *inf = fopen(name, "r");
_lines = NULL;
_lines = nullptr;
if (!inf) {
printf("Unable to open file %s\n", name);
getchar();
@ -54,7 +54,7 @@ uint32 crop(char *line) {
char *TextFile::giveLine(uint32 num) {
if (num >= _numLines)
return NULL;
return nullptr;
else
return _lines[num];
}

View file

@ -24,7 +24,7 @@
#include "cpthelp.h"
void assertEmpty(CptObj *cpt) {
assert((cpt->len == 0) && (cpt->data == NULL) && (cpt->dbgName == NULL) && (cpt->type == 0));
assert((cpt->len == 0) && (cpt->data == nullptr) && (cpt->dbgName == nullptr) && (cpt->type == 0));
}
uint16 getInfo(const char *line, const char *type, char *nameDest) {