Skip to content

Commit 45750fc

Browse files
committed
foundation: code cleanup
1 parent ee36dc1 commit 45750fc

3 files changed

Lines changed: 23 additions & 5 deletions

File tree

7800bas.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ int main (int argc, char *argv[])
288288
}
289289
}
290290
c = fgets (code, 500, preprocessedfd); // get next line from input
291+
if (!c)
292+
break; //end of file
291293
incline ();
292294
strcpy (displaycode, code);
293295

@@ -374,8 +376,6 @@ int main (int argc, char *argv[])
374376
}
375377
if (strcmp (mycode, code))
376378
strcpy (code, mycode);
377-
if (!c)
378-
break; //end of file
379379

380380
// preprocessing removed in favor of a simplistic lex-based preprocessor
381381

@@ -462,6 +462,7 @@ int main (int argc, char *argv[])
462462
if (preprocessedfd != NULL && preprocessedfd != stdin) {
463463
fclose(preprocessedfd);
464464
}
465+
465466
if (preproc_buffer != NULL) {
466467
free(preproc_buffer);
467468
preproc_buffer = NULL;

keywords.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,11 +561,24 @@ void keywords (char **cstatement)
561561
&& (statement[0][lastc - 3] == 't')
562562
&& (statement[0][lastc - 2] == 'h')
563563
&& (statement[0][lastc - 1] == 'e') && (statement[0][lastc - 0] == 'n')))
564-
return;
564+
{
565+
free (deallocstatement);
566+
freemem (deallocorstatement);
567+
freemem (deallocelstatement);
568+
return;
569+
}
570+
565571

566572
removeCR (statement[1]);
567-
if (statement[1][0]==0)
568-
return;
573+
574+
if (statement[1][0]==0)
575+
{
576+
free (deallocstatement);
577+
freemem (deallocorstatement);
578+
freemem (deallocelstatement);
579+
return;
580+
}
581+
569582
sprintf (errorcode, "unknown keyword '%s'.", statement[1]);
570583
prerror (&errorcode[0]);
571584
exit (1);

statements.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2207,6 +2207,9 @@ void plotmapfile (char **statement)
22072207
int palettevalues[2048];
22082208
int graphicmodes[2048];
22092209

2210+
memset(palettevalues, 0, sizeof(palettevalues));
2211+
memset(graphicmodes, 0, sizeof(graphicmodes));
2212+
22102213
assertminimumargs (statement, "plotmapfile", 6);
22112214

22122215
x = strictatoi (statement[4]);
@@ -5146,6 +5149,7 @@ void barf_graphic_file (void)
51465149
int graphics_addr[256];
51475150
int graphics_addr_absolute[256];
51485151
int tightpacked[256];
5152+
memset(tightpacked, 0, sizeof(tightpacked));
51495153
int dmaholeindex = 0;
51505154

51515155
// In 7800basic, the graphics blocks are used up from back to front of the rom/bank.

0 commit comments

Comments
 (0)