Use BB_FEATURE_CLEAN_UP where appropriate
authorEric Andersen <andersen@codepoet.org>
Tue, 25 Jul 2000 18:01:20 +0000 (18:01 -0000)
committerEric Andersen <andersen@codepoet.org>
Tue, 25 Jul 2000 18:01:20 +0000 (18:01 -0000)
 -Erik

12 files changed:
cmdedit.c
coreutils/dd.c
dd.c
editors/sed.c
fsck_minix.c
mount.c
sed.c
shell/cmdedit.c
umount.c
util-linux/fsck_minix.c
util-linux/mount.c
util-linux/umount.c

index 0de18e81f6bf4695e2840ce898959ca1999fccb0..0ce64beebf130c00943866cda8edab6cefb2c910 100644 (file)
--- a/cmdedit.c
+++ b/cmdedit.c
@@ -115,6 +115,18 @@ void cmdedit_reset_term(void)
        if (reset_term)
                /* sparc and other have broken termios support: use old termio handling. */
                setTermSettings(fileno(stdin), (void*) &initial_settings);
+#ifdef BB_FEATURE_CLEAN_UP
+       if (his_front) {
+               struct history *n;
+               //while(his_front!=his_end) {
+               while(his_front!=his_end) {
+                       n = his_front->n;
+                       free(his_front->s);
+                       free(his_front);
+                       his_front=n;
+               }
+       }
+#endif
 }
 
 void clean_up_and_die(int sig)
index 86899194c2b8537636d4fbde089c0333249063f6..6df2588ca43238bcbff4e216bbc42a123d2939e8 100644 (file)
@@ -173,7 +173,7 @@ extern int dd_main(int argc, char **argv)
   cleanup:
        /* Note that we are not freeing memory or closing
         * files here, to save a few bytes. */
-#if 0
+#ifdef BB_FEATURE_CLEAN_UP
        close(inFd);
        close(outFd);
        free(buf);
diff --git a/dd.c b/dd.c
index 86899194c2b8537636d4fbde089c0333249063f6..6df2588ca43238bcbff4e216bbc42a123d2939e8 100644 (file)
--- a/dd.c
+++ b/dd.c
@@ -173,7 +173,7 @@ extern int dd_main(int argc, char **argv)
   cleanup:
        /* Note that we are not freeing memory or closing
         * files here, to save a few bytes. */
-#if 0
+#ifdef BB_FEATURE_CLEAN_UP
        close(inFd);
        close(outFd);
        free(buf);
index b54a9bb9c3aac5f135ae28666aa0bd563fff746a..69a5e032477864aee304b9192d61fbc0c9c372e0 100644 (file)
@@ -92,7 +92,7 @@ static int ncmds = 0; /* number of sed commands */
 
 /*static char *cur_file = NULL;*/ /* file currently being processed XXX: do I need this? */
 
-#if 0
+#ifdef BB_FEATURE_CLEAN_UP
 static void destroy_cmd_strs()
 {
        if (sed_cmds == NULL)
@@ -663,7 +663,7 @@ extern int sed_main(int argc, char **argv)
 {
        int opt;
 
-#if 0
+#ifdef BB_FEATURE_CLEAN_UP
        /* destroy command strings on exit */
        if (atexit(destroy_cmd_strs) == -1) {
                perror("sed");
index c3c493fd2fe8345bf86f488b6dd4712132a08afc..f980fe9ea7c7a19f87fc62556d85b6a5edddde59 100644 (file)
@@ -1319,7 +1319,7 @@ static void alloc_name_list(void)
                name_list[i] = xmalloc(sizeof(char) * BUFSIZ + 1);
 }
 
-#if 0
+#ifdef BB_FEATURE_CLEAN_UP
 /* execute this atexit() to deallocate name_list[] */
 /* piptigger was here */
 static void free_name_list(void)
@@ -1344,9 +1344,11 @@ extern int fsck_minix_main(int argc, char **argv)
        int retcode = 0;
 
        alloc_name_list();
+#ifdef BB_FEATURE_CLEAN_UP
        /* Don't bother to free memory.  Exit does
         * that automagically, so we can save a few bytes */
-       //atexit(free_name_list);
+       atexit(free_name_list);
+#endif
 
        if (INODE_SIZE * MINIX_INODES_PER_BLOCK != BLOCK_SIZE)
                die("bad inode size");
diff --git a/mount.c b/mount.c
index 610d12d3419901ea3ab4bec234cd66fc4a9f93f8..6e95cdc793317f2fca9176440ff44931c7046091 100644 (file)
--- a/mount.c
+++ b/mount.c
@@ -347,9 +347,9 @@ extern int mount_main(int argc, char **argv)
                                        mntentlist[i].mnt_opts, mntentlist[i].mnt_freq, 
                                        mntentlist[i].mnt_passno);
                }
+#ifdef BB_FEATURE_CLEAN_UP
                /* Don't bother to close files or free memory.  Exit 
                 * does that automagically, so we can save a few bytes */
-#if 0
                free( mntentlist);
                close(fd);
 #endif
diff --git a/sed.c b/sed.c
index b54a9bb9c3aac5f135ae28666aa0bd563fff746a..69a5e032477864aee304b9192d61fbc0c9c372e0 100644 (file)
--- a/sed.c
+++ b/sed.c
@@ -92,7 +92,7 @@ static int ncmds = 0; /* number of sed commands */
 
 /*static char *cur_file = NULL;*/ /* file currently being processed XXX: do I need this? */
 
-#if 0
+#ifdef BB_FEATURE_CLEAN_UP
 static void destroy_cmd_strs()
 {
        if (sed_cmds == NULL)
@@ -663,7 +663,7 @@ extern int sed_main(int argc, char **argv)
 {
        int opt;
 
-#if 0
+#ifdef BB_FEATURE_CLEAN_UP
        /* destroy command strings on exit */
        if (atexit(destroy_cmd_strs) == -1) {
                perror("sed");
index 0de18e81f6bf4695e2840ce898959ca1999fccb0..0ce64beebf130c00943866cda8edab6cefb2c910 100644 (file)
@@ -115,6 +115,18 @@ void cmdedit_reset_term(void)
        if (reset_term)
                /* sparc and other have broken termios support: use old termio handling. */
                setTermSettings(fileno(stdin), (void*) &initial_settings);
+#ifdef BB_FEATURE_CLEAN_UP
+       if (his_front) {
+               struct history *n;
+               //while(his_front!=his_end) {
+               while(his_front!=his_end) {
+                       n = his_front->n;
+                       free(his_front->s);
+                       free(his_front);
+                       his_front=n;
+               }
+       }
+#endif
 }
 
 void clean_up_and_die(int sig)
index df075f7d9f14e413fdbc999cbe508285b6d3b90a..6a5e4cad8bc70c5caf0af91ef7e6b251ee3c3dbc 100644 (file)
--- a/umount.c
+++ b/umount.c
@@ -142,7 +142,7 @@ char *mtab_next(void **iter)
 
 /* Don't bother to clean up, since exit() does that 
  * automagically, so we can save a few bytes */
-#if 0
+#ifdef BB_FEATURE_CLEAN_UP
 void mtab_free(void)
 {
        struct _mtab_entry_t *this, *next;
@@ -235,6 +235,9 @@ extern int umount_main(int argc, char **argv)
        if (argc < 2) {
                usage(umount_usage);
        }
+#ifdef BB_FEATURE_CLEAN_UP
+       atexit(mtab_free);
+#endif
 
        /* Parse any options */
        while (--argc > 0 && **(++argv) == '-') {
index c3c493fd2fe8345bf86f488b6dd4712132a08afc..f980fe9ea7c7a19f87fc62556d85b6a5edddde59 100644 (file)
@@ -1319,7 +1319,7 @@ static void alloc_name_list(void)
                name_list[i] = xmalloc(sizeof(char) * BUFSIZ + 1);
 }
 
-#if 0
+#ifdef BB_FEATURE_CLEAN_UP
 /* execute this atexit() to deallocate name_list[] */
 /* piptigger was here */
 static void free_name_list(void)
@@ -1344,9 +1344,11 @@ extern int fsck_minix_main(int argc, char **argv)
        int retcode = 0;
 
        alloc_name_list();
+#ifdef BB_FEATURE_CLEAN_UP
        /* Don't bother to free memory.  Exit does
         * that automagically, so we can save a few bytes */
-       //atexit(free_name_list);
+       atexit(free_name_list);
+#endif
 
        if (INODE_SIZE * MINIX_INODES_PER_BLOCK != BLOCK_SIZE)
                die("bad inode size");
index 610d12d3419901ea3ab4bec234cd66fc4a9f93f8..6e95cdc793317f2fca9176440ff44931c7046091 100644 (file)
@@ -347,9 +347,9 @@ extern int mount_main(int argc, char **argv)
                                        mntentlist[i].mnt_opts, mntentlist[i].mnt_freq, 
                                        mntentlist[i].mnt_passno);
                }
+#ifdef BB_FEATURE_CLEAN_UP
                /* Don't bother to close files or free memory.  Exit 
                 * does that automagically, so we can save a few bytes */
-#if 0
                free( mntentlist);
                close(fd);
 #endif
index df075f7d9f14e413fdbc999cbe508285b6d3b90a..6a5e4cad8bc70c5caf0af91ef7e6b251ee3c3dbc 100644 (file)
@@ -142,7 +142,7 @@ char *mtab_next(void **iter)
 
 /* Don't bother to clean up, since exit() does that 
  * automagically, so we can save a few bytes */
-#if 0
+#ifdef BB_FEATURE_CLEAN_UP
 void mtab_free(void)
 {
        struct _mtab_entry_t *this, *next;
@@ -235,6 +235,9 @@ extern int umount_main(int argc, char **argv)
        if (argc < 2) {
                usage(umount_usage);
        }
+#ifdef BB_FEATURE_CLEAN_UP
+       atexit(mtab_free);
+#endif
 
        /* Parse any options */
        while (--argc > 0 && **(++argv) == '-') {