mirror of
https://github.com/cc65/cc65.git
synced 2025-01-15 22:30:04 +00:00
Removed several memory leaks.
git-svn-id: svn://svn.cc65.org/cc65/trunk@5595 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
4c36a39814
commit
84d90343ea
@ -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)
|
||||
/* Dump a collection of attribute/value pairs for debugging */
|
||||
{
|
||||
@ -240,7 +252,7 @@ void SplitAddAttr (Collection* C, const char* Combined, const char* Name)
|
||||
|
||||
/* Release memory */
|
||||
SB_Done (&N);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
/* Create a new attribute */
|
||||
|
||||
void FreeAttr (Attr* A);
|
||||
/* Free an attribute structure */
|
||||
|
||||
void DumpAttrColl (const Collection* C);
|
||||
/* Dump a collection of attribute/value pairs for debugging */
|
||||
|
||||
@ -92,7 +95,7 @@ const Attr* GetAttr (const Collection* C, const char* Name);
|
||||
|
||||
const Attr* NeedAttr (const Collection* C, const char* Name, const char* Op);
|
||||
/* Search for an attribute with the given name and return it. If the attribute
|
||||
* is not found, the function terminates with an error using Op as additional
|
||||
* is not found, the function terminates with an error using Op as additional
|
||||
* context in the error message.
|
||||
*/
|
||||
|
||||
@ -123,6 +126,9 @@ Collection* ParseAttrList (const char* List, const char** NameList, unsigned Nam
|
||||
* containing Attr entries.
|
||||
*/
|
||||
|
||||
void FreeAttrList (Collection* C);
|
||||
/* Free a list of attributes */
|
||||
|
||||
|
||||
|
||||
/* End of attr.h */
|
||||
|
@ -81,7 +81,8 @@ void FreeBitmap (Bitmap* B)
|
||||
{
|
||||
/* Alloc NULL pointers */
|
||||
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);
|
||||
}
|
||||
@ -190,7 +191,7 @@ unsigned GetBitmapColors (const Bitmap* B)
|
||||
case bmRGB:
|
||||
case bmRGBA: return (1U << 24);
|
||||
default: Internal ("Unknown bitmap type %u", B->Type);
|
||||
}
|
||||
}
|
||||
/* NOTREACHED */
|
||||
return 0;
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ static void OptConvertTo (const char* Opt attribute ((unused)), const char* Arg)
|
||||
SetOutputData (ConvertTo (C, A));
|
||||
|
||||
/* 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);
|
||||
|
||||
/* 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);
|
||||
|
||||
/* Delete the attribute list */
|
||||
FreeCollection (A);
|
||||
FreeAttrList (A);
|
||||
}
|
||||
|
||||
|
||||
|
@ -437,6 +437,9 @@ Bitmap* ReadPCXFile (const Collection* A)
|
||||
/* Close the file */
|
||||
fclose (F);
|
||||
|
||||
/* Free memory for the scan line */
|
||||
xfree (L);
|
||||
|
||||
/* Free the PCX header */
|
||||
FreePCXHeader (P);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user