commit 8ce3a83e5a7de9348b55ed9f7ddcb4de0e51c82a
Author:     Quentin Rameau <[email protected]>
AuthorDate: Sat Jun 4 12:28:02 2016 +0200
Commit:     Quentin Rameau <[email protected]>
CommitDate: Sat Jun 4 12:40:16 2016 +0200

    [driver] remove cleanup: clean in build and terminate
    
    Unlink failed files only on error, when terminate is called.

diff --git a/driver/posix/scc.c b/driver/posix/scc.c
index f164faf..098090d 100644
--- a/driver/posix/scc.c
+++ b/driver/posix/scc.c
@@ -46,23 +46,6 @@ static int failedtool = NR_TOOLS;
 static int Eflag, Sflag, kflag;
 
 static void
-cleanup(void)
-{
-       struct tool *t;
-       int i;
-
-       for (i = 0; i < NR_TOOLS + 1; ++i) {
-               t = &tools[i];
-               if (t->outfile) {
-                       if (i > failedtool)
-                               unlink(t->outfile);
-                       free(t->outfile);
-                       t->outfile = NULL;
-               }
-       }
-}
-
-static void
 terminate(void)
 {
        struct tool *t;
@@ -306,7 +289,10 @@ build(char *file)
        for (i = 0; i < NR_TOOLS; ++i)
                checktool(i);
 
-       cleanup();
+       for (i = 0; i < NR_TOOLS; ++i) {
+               free(tools[i].outfile);
+               tools[i].outfile = NULL;
+       }
 }
 
 static void

Reply via email to