mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Free all the charmaps after parsing
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
#define DEFAULT_CHARMAP_NAME "main"
|
#define DEFAULT_CHARMAP_NAME "main"
|
||||||
|
|
||||||
struct Charmap *charmap_New(char const *name, char const *baseName);
|
struct Charmap *charmap_New(char const *name, char const *baseName);
|
||||||
|
void charmap_Cleanup(void);
|
||||||
void charmap_Set(char const *name);
|
void charmap_Set(char const *name);
|
||||||
void charmap_Push(void);
|
void charmap_Push(void);
|
||||||
void charmap_Pop(void);
|
void charmap_Pop(void);
|
||||||
|
|||||||
@@ -104,6 +104,19 @@ struct Charmap *charmap_New(char const *name, char const *baseName)
|
|||||||
return charmap;
|
return charmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void freeCharmap(void *_charmap, void *)
|
||||||
|
{
|
||||||
|
struct Charmap *charmap = (struct Charmap *)_charmap;
|
||||||
|
|
||||||
|
free(charmap->name);
|
||||||
|
free(charmap);
|
||||||
|
}
|
||||||
|
|
||||||
|
void charmap_Cleanup(void)
|
||||||
|
{
|
||||||
|
hash_ForEach(charmaps, freeCharmap, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
void charmap_Set(char const *name)
|
void charmap_Set(char const *name)
|
||||||
{
|
{
|
||||||
struct Charmap **charmap = (struct Charmap **)hash_GetNode(charmaps, name);
|
struct Charmap **charmap = (struct Charmap **)hash_GetNode(charmaps, name);
|
||||||
|
|||||||
@@ -412,6 +412,9 @@ int main(int argc, char *argv[])
|
|||||||
if (yyparse() != 0 && nbErrors == 0)
|
if (yyparse() != 0 && nbErrors == 0)
|
||||||
nbErrors = 1;
|
nbErrors = 1;
|
||||||
|
|
||||||
|
// Free all charmaps (they're not needed after parsing)
|
||||||
|
charmap_Cleanup();
|
||||||
|
|
||||||
if (dependfile)
|
if (dependfile)
|
||||||
fclose(dependfile);
|
fclose(dependfile);
|
||||||
free(targetFileName);
|
free(targetFileName);
|
||||||
|
|||||||
@@ -193,13 +193,6 @@ static void printUsage(void)
|
|||||||
stderr);
|
stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleans up what has been done
|
|
||||||
// Mostly here to please tools such as `valgrind` so actual errors can be seen
|
|
||||||
static void cleanup(void)
|
|
||||||
{
|
|
||||||
obj_Cleanup();
|
|
||||||
}
|
|
||||||
|
|
||||||
enum ScrambledRegion {
|
enum ScrambledRegion {
|
||||||
SCRAMBLE_ROMX,
|
SCRAMBLE_ROMX,
|
||||||
SCRAMBLE_SRAM,
|
SCRAMBLE_SRAM,
|
||||||
@@ -465,5 +458,6 @@ int main(int argc, char *argv[])
|
|||||||
out_WriteFiles();
|
out_WriteFiles();
|
||||||
|
|
||||||
// Do cleanup before quitting, though.
|
// Do cleanup before quitting, though.
|
||||||
cleanup();
|
// Mostly here to please tools such as `valgrind` so actual errors can be seen
|
||||||
|
obj_Cleanup();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user