Removed several memory leaks.
git-svn-id: svn://svn.cc65.org/cc65/trunk@5595 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -87,6 +87,18 @@ Attr* NewAttr (const char* Name, const char* Value)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void FreeAttr (Attr* A)
|
||||||
|
/* Free an attribute structure */
|
||||||
|
{
|
||||||
|
/* Allow NULL pointers */
|
||||||
|
if (A) {
|
||||||
|
xfree (A->Name);
|
||||||
|
xfree (A);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void DumpAttrColl (const Collection* C)
|
void DumpAttrColl (const Collection* C)
|
||||||
/* Dump a collection of attribute/value pairs for debugging */
|
/* Dump a collection of attribute/value pairs for debugging */
|
||||||
{
|
{
|
||||||
@@ -296,3 +308,19 @@ Collection* ParseAttrList (const char* List, const char** NameList, unsigned Nam
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void FreeAttrList (Collection* C)
|
||||||
|
/* Free a list of attributes */
|
||||||
|
{
|
||||||
|
unsigned I;
|
||||||
|
|
||||||
|
/* Walk over the collection and free all attributes */
|
||||||
|
for (I = 0; I < CollCount (C); ++I) {
|
||||||
|
FreeAttr (CollAtUnchecked (C, I));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Free the collection itself */
|
||||||
|
FreeCollection (C);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -75,6 +75,9 @@ struct Attr {
|
|||||||
Attr* NewAttr (const char* Name, const char* Value);
|
Attr* NewAttr (const char* Name, const char* Value);
|
||||||
/* Create a new attribute */
|
/* Create a new attribute */
|
||||||
|
|
||||||
|
void FreeAttr (Attr* A);
|
||||||
|
/* Free an attribute structure */
|
||||||
|
|
||||||
void DumpAttrColl (const Collection* C);
|
void DumpAttrColl (const Collection* C);
|
||||||
/* Dump a collection of attribute/value pairs for debugging */
|
/* Dump a collection of attribute/value pairs for debugging */
|
||||||
|
|
||||||
@@ -123,6 +126,9 @@ Collection* ParseAttrList (const char* List, const char** NameList, unsigned Nam
|
|||||||
* containing Attr entries.
|
* containing Attr entries.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
void FreeAttrList (Collection* C);
|
||||||
|
/* Free a list of attributes */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* End of attr.h */
|
/* End of attr.h */
|
||||||
|
|||||||
@@ -81,7 +81,8 @@ void FreeBitmap (Bitmap* B)
|
|||||||
{
|
{
|
||||||
/* Alloc NULL pointers */
|
/* Alloc NULL pointers */
|
||||||
if (B != 0) {
|
if (B != 0) {
|
||||||
/* Free the palette and then the bitmap */
|
/* Free name, palette and then the bitmap */
|
||||||
|
SB_Done (&B->Name);
|
||||||
xfree (B->Pal);
|
xfree (B->Pal);
|
||||||
xfree(B);
|
xfree(B);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ static void OptConvertTo (const char* Opt attribute ((unused)), const char* Arg)
|
|||||||
SetOutputData (ConvertTo (C, A));
|
SetOutputData (ConvertTo (C, A));
|
||||||
|
|
||||||
/* Delete the attribute list */
|
/* Delete the attribute list */
|
||||||
FreeCollection (A);
|
FreeAttrList (A);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -217,7 +217,7 @@ static void OptRead (const char* Opt attribute ((unused)), const char* Arg)
|
|||||||
B = C = ReadInputFile (A);
|
B = C = ReadInputFile (A);
|
||||||
|
|
||||||
/* Delete the attribute list */
|
/* Delete the attribute list */
|
||||||
FreeCollection (A);
|
FreeAttrList (A);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -286,7 +286,7 @@ static void OptWrite (const char* Opt attribute ((unused)), const char* Arg)
|
|||||||
WriteOutputFile (D, A);
|
WriteOutputFile (D, A);
|
||||||
|
|
||||||
/* Delete the attribute list */
|
/* Delete the attribute list */
|
||||||
FreeCollection (A);
|
FreeAttrList (A);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -437,6 +437,9 @@ Bitmap* ReadPCXFile (const Collection* A)
|
|||||||
/* Close the file */
|
/* Close the file */
|
||||||
fclose (F);
|
fclose (F);
|
||||||
|
|
||||||
|
/* Free memory for the scan line */
|
||||||
|
xfree (L);
|
||||||
|
|
||||||
/* Free the PCX header */
|
/* Free the PCX header */
|
||||||
FreePCXHeader (P);
|
FreePCXHeader (P);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user