Remove all the cleanup functions. There is no reason to free memory

just before exiting (especially given the number of memory leaks) -
it just costs time.
This commit is contained in:
Hartmut Brandt 2004-12-17 13:20:19 +00:00
parent db8d970ac4
commit 674a77f864
10 changed files with 6 additions and 185 deletions

View File

@ -85,8 +85,6 @@ __FBSDID("$FreeBSD$");
* is out-of-date.
*
* Arch_Init Initialize this module.
*
* Arch_End Cleanup this module.
*/
#include <sys/types.h>
@ -114,7 +112,6 @@ typedef struct Arch {
size_t fnamesize; /* Size of the string table */
} Arch;
static void ArchFree(void *);
static struct ar_hdr *ArchStatMember(char *, char *, Boolean);
static FILE *ArchFindMember(char *, char *, struct ar_hdr *, char *);
#if defined(__svr4__) || defined(__SVR4) || defined(__ELF__)
@ -122,38 +119,6 @@ static FILE *ArchFindMember(char *, char *, struct ar_hdr *, char *);
static int ArchSVR4Entry(Arch *, char *, size_t, FILE *);
#endif
/*-
*-----------------------------------------------------------------------
* ArchFree --
* Free memory used by an archive
*
* Results:
* None.
*
* Side Effects:
* None.
*
*-----------------------------------------------------------------------
*/
static void
ArchFree(void *ap)
{
Arch *a = ap;
Hash_Search search;
Hash_Entry *entry;
/* Free memory from hash entries */
for (entry = Hash_EnumFirst(&a->members, &search);
entry != NULL;
entry = Hash_EnumNext(&search))
free(Hash_GetValue(entry));
free(a->name);
free(a->fnametab);
Hash_DeleteTable(&a->members);
free(a);
}
/*-
*-----------------------------------------------------------------------
* Arch_ParseArchive --
@ -1184,23 +1149,3 @@ void
Arch_Init(void)
{
}
/*-
*-----------------------------------------------------------------------
* Arch_End --
* Cleanup things for this module.
*
* Results:
* None.
*
* Side Effects:
* The 'archives' list is freed
*
*-----------------------------------------------------------------------
*/
void
Arch_End(void)
{
Lst_Destroy(&archives, ArchFree);
}

View File

@ -51,8 +51,6 @@ __FBSDID("$FreeBSD$");
* The interface for this module is:
* Dir_Init Initialize the module.
*
* Dir_End Cleanup the module.
*
* Dir_HasWildcards Returns TRUE if the name given it needs to
* be wildcard-expanded.
*
@ -242,31 +240,6 @@ Dir_InitDot(void)
dot->refCount += 1;
}
/*-
*-----------------------------------------------------------------------
* Dir_End --
* cleanup things for this module
*
* Results:
* none
*
* Side Effects:
* none
*-----------------------------------------------------------------------
*/
void
Dir_End(void)
{
dot->refCount -= 1;
Dir_Destroy(dot);
Dir_ClearPath(&dirSearchPath);
Lst_Destroy(&dirSearchPath, NOFREE);
Dir_ClearPath(&openDirectories);
Lst_Destroy(&openDirectories, NOFREE);
Hash_DeleteTable(&mtimes);
}
/*-
*-----------------------------------------------------------------------
* DirFindName --

View File

@ -56,7 +56,6 @@ typedef struct Path {
void Dir_Init(void);
void Dir_InitDot(void);
void Dir_End(void);
Boolean Dir_HasWildcards(const char *);
void Dir_Expand(char *, Lst *, Lst *);
char *Dir_FindFile(char *, Lst *);

View File

@ -885,14 +885,6 @@ main(int argc, char **argv)
if (DEBUG(GRAPH2))
Targ_PrintGraph(2);
Suff_End();
Targ_End();
Arch_End();
str_end();
Var_End();
Parse_End();
Dir_End();
if (queryFlag && outOfDate)
return (1);
else

View File

@ -48,7 +48,6 @@ int Arch_MemMTime(GNode *);
void Arch_FindLib(GNode *, Lst *);
Boolean Arch_LibOODate(GNode *);
void Arch_Init(void);
void Arch_End(void);
/* compat.c */
void Compat_Run(Lst *);
@ -86,13 +85,11 @@ void Parse_DoVar(char *, GNode *);
void Parse_AddIncludeDir(char *);
void Parse_File(char *, FILE *);
void Parse_Init(void);
void Parse_End(void);
void Parse_FromString(char *, int);
void Parse_MainName(Lst *);
/* str.c */
void str_init(void);
void str_end(void);
char *str_concat(const char *, const char *, int);
char **brk_string(char *, int *, Boolean);
int Str_Match(const char *, const char *);
@ -112,12 +109,10 @@ void Suff_AddLib(char *);
void Suff_FindDeps(GNode *);
void Suff_SetNull(char *);
void Suff_Init(void);
void Suff_End(void);
void Suff_PrintAll(void);
/* targ.c */
void Targ_Init(void);
void Targ_End(void);
GNode *Targ_NewGN(char *);
GNode *Targ_FindNode(char *, int);
void Targ_FindList(Lst *, Lst *, int);
@ -142,5 +137,4 @@ char *Var_Subst(char *, char *, GNode *, Boolean);
char *Var_GetTail(char *);
char *Var_GetHead(char *);
void Var_Init(void);
void Var_End(void);
void Var_Dump(GNode *);

View File

@ -64,8 +64,6 @@ __FBSDID("$FreeBSD$");
* called before anything else in this module
* is used.
*
* Parse_End Cleanup the module
*
* Parse_File Function used to parse a makefile. It must
* be given the name of the file, which should
* already have been opened, and a function
@ -2522,17 +2520,6 @@ Parse_Init(void)
mainNode = NULL;
}
void
Parse_End(void)
{
Lst_Destroy(&targets, NOFREE);
Lst_Destroy(&sysIncPath, Dir_Destroy);
Lst_Destroy(&parseIncPath, Dir_Destroy);
Lst_Destroy(&includes, NOFREE); /* Should be empty now */
}
/*-
*-----------------------------------------------------------------------
* Parse_MainName --

View File

@ -60,24 +60,6 @@ str_init(void)
argv[0] = Var_Value(".MAKE", VAR_GLOBAL, &p1);
}
/*
* str_end --
* Cleanup the strings package
*
*/
void
str_end(void)
{
if (argv) {
if (argv[0])
free(argv[0]);
free(argv);
}
if (buffer)
free(buffer);
}
/*-
* str_concat --
* concatenate the two strings, inserting a space or slash between them.

View File

@ -49,8 +49,6 @@ __FBSDID("$FreeBSD$");
* Interface:
* Suff_Init Initialize all things to do with suffixes.
*
* Suff_End Cleanup the module
*
* Suff_DoPaths This function is used to make life easier
* when searching for a file according to its
* suffix. It takes the global search path,
@ -160,7 +158,6 @@ static Suff *emptySuff; /* The empty suffix required for POSIX
* single-suffix transformation rules */
static void SuffFree(void *);
static void SuffInsert(Lst *, Suff *);
static void SuffRemove(Lst *, Suff *);
static Boolean SuffParseTransform(char *, Suff **, Suff **);
@ -339,6 +336,11 @@ SuffGNHasNameP(const void *gn, const void *name)
/*********** Maintenance Functions ************/
#if 0
/*
* Keep this function for now until it is clear why a .SUFFIXES: doesn't
* actually delete the suffixes but just puts them on the suffClean list.
*/
/*-
*-----------------------------------------------------------------------
* SuffFree --
@ -370,6 +372,7 @@ SuffFree(void *sp)
free(s->name);
free(s);
}
#endif
/*-
*-----------------------------------------------------------------------
@ -2244,31 +2247,6 @@ Suff_Init(void)
suffNull->refCount = 1;
}
/*-
*----------------------------------------------------------------------
* Suff_End --
* Cleanup the this module
*
* Results:
* None
*
* Side Effects:
* The memory is free'd.
*----------------------------------------------------------------------
*/
void
Suff_End(void)
{
Lst_Destroy(&sufflist, SuffFree);
Lst_Destroy(&suffClean, SuffFree);
if (suffNull)
SuffFree(suffNull);
Lst_Destroy(&srclist, NOFREE);
Lst_Destroy(&transforms, NOFREE);
}
/********************* DEBUGGING FUNCTIONS **********************/
static int

View File

@ -50,8 +50,6 @@ __FBSDID("$FreeBSD$");
* Interface:
* Targ_Init Initialization procedure.
*
* Targ_End Cleanup the module
*
* Targ_NewGN Create a new GNode for the passed target
* (string). The node is *not* placed in the
* hash table, though all its fields are
@ -118,26 +116,6 @@ Targ_Init(void)
Hash_InitTable(&targets, HTSIZE);
}
/*-
*-----------------------------------------------------------------------
* Targ_End --
* Finalize this module
*
* Results:
* None
*
* Side Effects:
* All lists and gnodes are cleared
*-----------------------------------------------------------------------
*/
void
Targ_End(void)
{
Lst_Destroy(&allTargets, NOFREE);
Hash_DeleteTable(&targets);
}
/*-
*-----------------------------------------------------------------------
* Targ_NewGN --

View File

@ -1920,15 +1920,8 @@ Var_Init(void)
VAR_GLOBAL = Targ_NewGN("Global");
VAR_CMD = Targ_NewGN("Command");
}
void
Var_End(void)
{
}
/****************** PRINT DEBUGGING INFO *****************/
static int
VarPrintVar(void *vp, void *dummy __unused)