mirror of
https://github.com/cc65/cc65.git
synced 2024-11-16 18:08:04 +00:00
Fixed a rather large memory leak.
git-svn-id: svn://svn.cc65.org/cc65/trunk@5102 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
edca940a86
commit
67692e51f1
@ -72,6 +72,15 @@ static CodeRange* NewCodeRange (Segment* Seg, unsigned long Offs, unsigned long
|
||||
|
||||
|
||||
|
||||
static void FreeCodeRange (CodeRange* R)
|
||||
/* Free a CodeRange structure */
|
||||
{
|
||||
/* Just free the memory */
|
||||
xfree (R);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static LineInfo* NewLineInfo (void)
|
||||
/* Create and return a new LineInfo struct with mostly empty fields */
|
||||
{
|
||||
@ -93,6 +102,30 @@ static LineInfo* NewLineInfo (void)
|
||||
|
||||
|
||||
|
||||
void FreeLineInfo (LineInfo* LI)
|
||||
/* Free a LineInfo structure. This function will not handle a non empty
|
||||
* Fragments collection, it can only be used to free incomplete line infos.
|
||||
*/
|
||||
{
|
||||
unsigned I;
|
||||
|
||||
/* Check, check, ... */
|
||||
PRECONDITION (CollCount (&LI->Fragments) == 0);
|
||||
|
||||
/* Free all the code ranges */
|
||||
for (I = 0; I < CollCount (&LI->CodeRanges); ++I) {
|
||||
FreeCodeRange (CollAtUnchecked (&LI->CodeRanges, I));
|
||||
}
|
||||
|
||||
/* Free the collections */
|
||||
DoneCollection (&LI->CodeRanges);
|
||||
|
||||
/* Free the structure itself */
|
||||
xfree (LI);
|
||||
}
|
||||
|
||||
|
||||
|
||||
LineInfo* GenLineInfo (const FilePos* Pos)
|
||||
/* Generate a new (internally used) line info with the given information */
|
||||
{
|
||||
|
@ -102,6 +102,11 @@ LineInfo* GenLineInfo (const FilePos* Pos);
|
||||
LineInfo* ReadLineInfo (FILE* F, struct ObjData* O);
|
||||
/* Read a line info from a file and return it */
|
||||
|
||||
void FreeLineInfo (LineInfo* LI);
|
||||
/* Free a LineInfo structure. This function will not handle a non empty
|
||||
* Fragments collection, it can only be used to free incomplete line infos.
|
||||
*/
|
||||
|
||||
void ReadLineInfoList (FILE* F, struct ObjData* O, Collection* LineInfos);
|
||||
/* Read a list of line infos stored as a list of indices in the object file,
|
||||
* make real line infos from them and place them into the passed collection.
|
||||
|
@ -105,14 +105,17 @@ void FreeObjData (ObjData* O)
|
||||
|
||||
/* Unused ObjData do only have the string pool, Exports and Imports. */
|
||||
for (I = 0; I < CollCount (&O->Exports); ++I) {
|
||||
FreeExport (CollAt (&O->Exports, I));
|
||||
FreeExport (CollAtUnchecked (&O->Exports, I));
|
||||
}
|
||||
DoneCollection (&O->Exports);
|
||||
for (I = 0; I < CollCount (&O->Imports); ++I) {
|
||||
FreeImport (CollAt (&O->Imports, I));
|
||||
FreeImport (CollAtUnchecked (&O->Imports, I));
|
||||
}
|
||||
DoneCollection (&O->Imports);
|
||||
DoneCollection (&O->DbgSyms);
|
||||
for (I = 0; I < CollCount (&O->LineInfos); ++I) {
|
||||
FreeLineInfo (CollAtUnchecked (&O->LineInfos, I));
|
||||
}
|
||||
DoneCollection (&O->LineInfos);
|
||||
xfree (O->Strings);
|
||||
DoneCollection (&O->Assertions);
|
||||
|
Loading…
Reference in New Issue
Block a user