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:
uz
2011-08-01 20:49:59 +00:00
parent edca940a86
commit 67692e51f1
3 changed files with 45 additions and 4 deletions

View File

@@ -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 */
{
@@ -245,4 +278,4 @@ void RelocLineInfo (Segment* S)