Assembler streaming output is first done via memory file, then flushed to host filing system when completed
Currently, Mpm is opening FILE * handles on global scope for OBJECT, LISTING, SYMBOL DEF and ADDRESS MAP files. The handles and filenames are stored in global variables and accessed via functions that process the file data.
As the assembler processes the source code, the output are streamed to files on disc during compilation progresses.
SQ reports a bunch of false positives about these global file handles not being closed correctly (leaking). All handles are correctly closed, howevver. It probably relates to various boolean global status variables and the file handles also are of global scope.
Fix these "bugs" by re-implementing all output via virtual memory files that mimic normal file I/O. Create a library for memory file output/update management.
Each memory file is assigned a pre-allocated memory buffer. As the file contents increases, and reaches the end of the buffer, a new buffer re-allocated and file contents moved over (transparently).
When the memory file is closed (completed), it is flushed to hosting file system in a single atomic operation using a temporary FILE * handle.
Using memory file as intermediate output, increases processing speed (less OS processing file I/O overhead) and simplify file management in Mpm.
Refactor existing read-only memory file functionality used to parse source code, into new memfile.c, and extend this functionality to also include output and update functionality.