diff --git a/include/link/assign.hpp b/include/link/assign.hpp index c2a13c99..e0c665b8 100644 --- a/include/link/assign.hpp +++ b/include/link/assign.hpp @@ -11,7 +11,4 @@ extern uint64_t nbSectionsToAssign; // Assigns all sections a slice of the address space void assign_AssignSections(); -// `free`s all assignment memory that was allocated -void assign_Cleanup(); - #endif // RGBDS_LINK_ASSIGN_H diff --git a/include/link/object.hpp b/include/link/object.hpp index 4b5ab0e4..9b65f68f 100644 --- a/include/link/object.hpp +++ b/include/link/object.hpp @@ -28,9 +28,4 @@ void obj_CheckAssertions(); */ void obj_Setup(unsigned int nbFiles); -/* - * `free`s all object memory that was allocated. - */ -void obj_Cleanup(); - #endif // RGBDS_LINK_OBJECT_H diff --git a/src/link/main.cpp b/src/link/main.cpp index 8cc3cb2a..c034eb86 100644 --- a/src/link/main.cpp +++ b/src/link/main.cpp @@ -342,6 +342,19 @@ next: 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[]) { // Parse options @@ -447,7 +460,7 @@ int main(int argc, char *argv[]) // Do cleanup before quitting, though. // Mostly here to please tools such as `valgrind` so actual errors can be seen - atexit(obj_Cleanup); + atexit(freeSections); // Read all object files first, for (obj_Setup(argc - curArgIndex); curArgIndex < argc; curArgIndex++) diff --git a/src/link/object.cpp b/src/link/object.cpp index 64475776..0a148b10 100644 --- a/src/link/object.cpp +++ b/src/link/object.cpp @@ -539,16 +539,3 @@ void obj_Setup(unsigned int 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); -} diff --git a/src/link/patch.cpp b/src/link/patch.cpp index d93d5fc9..9434b4c0 100644 --- a/src/link/patch.cpp +++ b/src/link/patch.cpp @@ -240,7 +240,6 @@ static int32_t computeRPNExpr(Patch const *patch, std::vector const &fil case RPN_BANK_SECT: // `expression` is not guaranteed to be '\0'-terminated. If it is not, // `getRPNByte` will have a fatal internal error. - // In either case, `getRPNByte` will not free `expression`. name = (char const *)expression; while (getRPNByte(&expression, &size, patch->src, patch->lineNo)) ;