[Frugalware-git] firepl: add a janitor function

James Buren ryuo at frugalware.org
Thu May 10 14:11:16 CEST 2012


Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=firepl.git;a=commitdiff;h=bfefbd8ec12dc7533299ff7c8c52a83c535ae706

commit bfefbd8ec12dc7533299ff7c8c52a83c535ae706
Author: James Buren <ryuo at frugalware.org>
Date:   Thu May 10 07:11:14 2012 -0500

add a janitor function

diff --git a/firepl.c b/firepl.c
index d7dd9bb..17eaffc 100644
--- a/firepl.c
+++ b/firepl.c
@@ -6,6 +6,21 @@

gpv *firepl;

+// Hey! I just mopped there.
+static void janitor(void)
+{
+	if(firepl)
+	{
+		if(firepl->cfgdirs)
+			pafree(firepl->cfgdirs,free);
+
+		if(firepl->datadirs)
+			pafree(firepl->datadirs,free);
+
+		free(firepl);
+	}
+}
+
static bool parse_arguments(int argc,char **argv)
{
int opt;
@@ -54,6 +69,13 @@ extern int main(int argc,char **argv)
{
firepl = alloc0(gpv,1);

+	if(atexit(janitor))
+	{
+		eprintf("Failed to register janitor() with atexit().\n");
+
+		return EXIT_FAILURE;
+	}
+
if(!parse_arguments(argc,argv))
return EXIT_FAILURE;


More information about the Frugalware-git mailing list