We do not call malloc/free any more

This commit is contained in:
Rangi42
2024-03-02 08:16:30 -05:00
parent 19bb12754b
commit 52f8ecc347
5 changed files with 14 additions and 23 deletions

View File

@@ -11,7 +11,4 @@ extern uint64_t nbSectionsToAssign;
// Assigns all sections a slice of the address space // Assigns all sections a slice of the address space
void assign_AssignSections(); void assign_AssignSections();
// `free`s all assignment memory that was allocated
void assign_Cleanup();
#endif // RGBDS_LINK_ASSIGN_H #endif // RGBDS_LINK_ASSIGN_H

View File

@@ -28,9 +28,4 @@ void obj_CheckAssertions();
*/ */
void obj_Setup(unsigned int nbFiles); void obj_Setup(unsigned int nbFiles);
/*
* `free`s all object memory that was allocated.
*/
void obj_Cleanup();
#endif // RGBDS_LINK_OBJECT_H #endif // RGBDS_LINK_OBJECT_H

View File

@@ -342,6 +342,19 @@ next:
exit(1); exit(1);
} }
static void freeSection(Section *section)
{
for (Section *next; section; section = next) {
next = section->nextu;
delete section;
};
}
static void freeSections()
{
sect_ForEach(freeSection);
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
// Parse options // Parse options
@@ -447,7 +460,7 @@ int main(int argc, char *argv[])
// Do cleanup before quitting, though. // Do cleanup before quitting, though.
// Mostly here to please tools such as `valgrind` so actual errors can be seen // Mostly here to please tools such as `valgrind` so actual errors can be seen
atexit(obj_Cleanup); atexit(freeSections);
// Read all object files first, // Read all object files first,
for (obj_Setup(argc - curArgIndex); curArgIndex < argc; curArgIndex++) for (obj_Setup(argc - curArgIndex); curArgIndex < argc; curArgIndex++)

View File

@@ -539,16 +539,3 @@ void obj_Setup(unsigned int nbFiles)
{ {
nodes.resize(nbFiles); nodes.resize(nbFiles);
} }
static void freeSection(Section *section)
{
for (Section *next; section; section = next) {
next = section->nextu;
delete section;
};
}
void obj_Cleanup()
{
sect_ForEach(freeSection);
}

View File

@@ -240,7 +240,6 @@ static int32_t computeRPNExpr(Patch const *patch, std::vector<Symbol> const &fil
case RPN_BANK_SECT: case RPN_BANK_SECT:
// `expression` is not guaranteed to be '\0'-terminated. If it is not, // `expression` is not guaranteed to be '\0'-terminated. If it is not,
// `getRPNByte` will have a fatal internal error. // `getRPNByte` will have a fatal internal error.
// In either case, `getRPNByte` will not free `expression`.
name = (char const *)expression; name = (char const *)expression;
while (getRPNByte(&expression, &size, patch->src, patch->lineNo)) while (getRPNByte(&expression, &size, patch->src, patch->lineNo))
; ;