Skip to content

Commit

Permalink
HOPKINS: Changed PTRNUL from being 0 to an explicitly allocated pointer.
Browse files Browse the repository at this point in the history
Some of the methods explicitly differentiate between having a 0 result for invalid/abort versus PTRNUL return values
  • Loading branch information
dreammaster committed Oct 10, 2012
1 parent 02df605 commit 7ca9d21
Show file tree
Hide file tree
Showing 9 changed files with 215 additions and 205 deletions.
6 changes: 3 additions & 3 deletions engines/hopkins/anim.cpp
Expand Up @@ -777,13 +777,13 @@ void AnimationManager::CHARGE_ANIM(const Common::String &animName) {

void AnimationManager::CLEAR_ANIM() {
for (int idx = 0; idx < 35; ++idx) {
if (_vm->_globals.Bqe_Anim[idx].data != PTRNUL)
if (_vm->_globals.Bqe_Anim[idx].data != g_PTRNUL)
_vm->_globals.Bqe_Anim[idx].data = _vm->_globals.dos_free2(_vm->_globals.Bqe_Anim[idx].data);
_vm->_globals.Bqe_Anim[idx].field4 = 0;
}

for (int idx = 0; idx < 8; ++idx) {
if (_vm->_globals.Bank[idx].data != PTRNUL)
if (_vm->_globals.Bank[idx].data != g_PTRNUL)
_vm->_globals.Bank[idx].data = _vm->_globals.dos_free2(_vm->_globals.Bank[idx].data);
_vm->_globals.Bank[idx].field4 = 0;
_vm->_globals.Bank[idx].filename1 = "";
Expand Down Expand Up @@ -937,7 +937,7 @@ void AnimationManager::RECHERCHE_ANIM(const byte *data, int idx, int nbytes) {

if (nbytes < v6) {
_vm->_globals.Bqe_Anim[idx].field4 = 0;
_vm->_globals.Bqe_Anim[idx].data = PTRNUL;
_vm->_globals.Bqe_Anim[idx].data = g_PTRNUL;
}

++v6;
Expand Down
22 changes: 11 additions & 11 deletions engines/hopkins/files.cpp
Expand Up @@ -194,7 +194,7 @@ void FileManager::CONSTRUIT_FICHIER(const Common::String &hop, const Common::Str

byte *FileManager::LIBERE_FICHIER(byte *ptr) {
free(ptr);
return PTRNUL;
return g_PTRNUL;
}

byte *FileManager::RECHERCHE_CAT(const Common::String &file, int a2) {
Expand All @@ -208,7 +208,7 @@ byte *FileManager::RECHERCHE_CAT(const Common::String &file, int a2) {
case 1:
CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_INI.CAT");
if (!f.exists(_vm->_globals.NFICHIER))
return PTRNUL;
return g_PTRNUL;

ptr = CHARGE_FICHIER(_vm->_globals.NFICHIER);
CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_INI.RES");
Expand All @@ -217,7 +217,7 @@ byte *FileManager::RECHERCHE_CAT(const Common::String &file, int a2) {
case 2:
CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_REP.CAT");
if (!f.exists(_vm->_globals.NFICHIER))
return PTRNUL;
return g_PTRNUL;

ptr = CHARGE_FICHIER(_vm->_globals.NFICHIER);
CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_REP.RES");
Expand All @@ -226,7 +226,7 @@ byte *FileManager::RECHERCHE_CAT(const Common::String &file, int a2) {
case 3:
CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_LIN.CAT");
if (!f.exists(_vm->_globals.NFICHIER))
return PTRNUL;
return g_PTRNUL;

ptr = CHARGE_FICHIER(_vm->_globals.NFICHIER);
CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_LIN.RES");
Expand All @@ -235,7 +235,7 @@ byte *FileManager::RECHERCHE_CAT(const Common::String &file, int a2) {
case 4:
CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, "RES_ANI.CAT");
if (!f.exists(_vm->_globals.NFICHIER))
return PTRNUL;
return g_PTRNUL;

ptr = CHARGE_FICHIER(_vm->_globals.NFICHIER);
CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, "RES_ANI.RES");
Expand All @@ -244,7 +244,7 @@ byte *FileManager::RECHERCHE_CAT(const Common::String &file, int a2) {
case 5:
CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, "RES_PER.CAT");
if (!f.exists(_vm->_globals.NFICHIER))
return PTRNUL;
return g_PTRNUL;

ptr = CHARGE_FICHIER(_vm->_globals.NFICHIER);
CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, "RES_PER.RES");
Expand All @@ -253,23 +253,23 @@ byte *FileManager::RECHERCHE_CAT(const Common::String &file, int a2) {
case 6:
CONSTRUIT_FICHIER(_vm->_globals.HOPIMAGE, "PIC.CAT");
if (!f.exists(_vm->_globals.NFICHIER))
return PTRNUL;
return g_PTRNUL;

ptr = CHARGE_FICHIER(_vm->_globals.NFICHIER);
break;

case 7:
CONSTRUIT_FICHIER(_vm->_globals.HOPANIM, "RES_SAN.CAT");
if (!f.exists(_vm->_globals.NFICHIER))
return PTRNUL;
return g_PTRNUL;

ptr = CHARGE_FICHIER(_vm->_globals.NFICHIER);
break;

case 8:
CONSTRUIT_FICHIER(_vm->_globals.HOPLINK, "RES_SLI.CAT");
if (!f.exists(_vm->_globals.NFICHIER))
return PTRNUL;
return g_PTRNUL;

ptr = CHARGE_FICHIER(_vm->_globals.NFICHIER);
break;
Expand All @@ -288,7 +288,7 @@ byte *FileManager::RECHERCHE_CAT(const Common::String &file, int a2) {
}

if (!f.exists(_vm->_globals.NFICHIER))
return PTRNUL;
return g_PTRNUL;

ptr = CHARGE_FICHIER(_vm->_globals.NFICHIER);
break;
Expand Down Expand Up @@ -331,7 +331,7 @@ byte *FileManager::RECHERCHE_CAT(const Common::String &file, int a2) {
f.seek(_vm->_globals.CAT_POSI);

byte *catData = _vm->_globals.dos_malloc2(_vm->_globals.CAT_TAILLE);
if (catData == PTRNUL)
if (catData == g_PTRNUL)
error("CHARGE_FICHIER");

bload_it(f, catData, _vm->_globals.CAT_TAILLE);
Expand Down
16 changes: 8 additions & 8 deletions engines/hopkins/font.cpp
Expand Up @@ -58,9 +58,9 @@ void FontManager::TEXTE_ON(int idx) {
txt.field0 = 1;
txt.field408 = 0;

if (txt.field400 != PTRNUL) {
if (txt.field400 != g_PTRNUL) {
_vm->_globals.dos_free2(txt.field400);
txt.field400 = PTRNUL;
txt.field400 = g_PTRNUL;
}
}

Expand All @@ -73,9 +73,9 @@ void FontManager::TEXTE_OFF(int idx) {
txt.field0 = 0;
txt.field408 = 0;

if (txt.field400 != PTRNUL) {
if (txt.field400 != g_PTRNUL) {
_vm->_globals.dos_free2(txt.field400);
txt.field400 = PTRNUL;
txt.field400 = g_PTRNUL;
}
}

Expand Down Expand Up @@ -250,7 +250,7 @@ void FontManager::BOITE(int idx, int fileIndex, const Common::String &filename,
v69 = 2048;
f.seek(Index[fileIndex]);
texte_tmp = _vm->_globals.dos_malloc2(2058);
if (texte_tmp == PTRNUL)
if (texte_tmp == g_PTRNUL)
error("temporary text");
f.read(texte_temp, 2048);
Expand Down Expand Up @@ -475,7 +475,7 @@ void FontManager::BOITE(int idx, int fileIndex, const Common::String &filename,
v49 = v51 * v53;
ptrd = _vm->_globals.dos_malloc2(v51 * v53);
if (ptrd == PTRNUL)
if (ptrd == g_PTRNUL)
error("Error allocating block (%d)", v49);
}
Expand Down Expand Up @@ -512,12 +512,12 @@ void FontManager::BOITE(int idx, int fileIndex, const Common::String &filename,
if (v32 == 6 || v32 == 1 || v32 == 3 || v32 == 5) {
v33 = idx;
if (Txt[v33].field400 != PTRNUL)
if (Txt[v33].field400 != g_PTRNUL)
Txt[v33].field400 = _vm->_globals.dos_free2(Txt[v33].field400);
v50 = v52 * v54;
ptre = dos_malloc2(v50 + 20);
if (ptre == PTRNUL)
if (ptre == g_PTRNUL)
error("Error allocating block (%d)", v50);
}
Expand Down

0 comments on commit 7ca9d21

Please sign in to comment.