Use BB_FEATURE_CLEAN_UP where appropriate

-Erik
This commit is contained in:
Eric Andersen 2000-07-25 18:01:20 +00:00
parent b9ea02c04b
commit b040d4f3da
12 changed files with 48 additions and 14 deletions

View File

@ -115,6 +115,18 @@ void cmdedit_reset_term(void)
if (reset_term) if (reset_term)
/* sparc and other have broken termios support: use old termio handling. */ /* sparc and other have broken termios support: use old termio handling. */
setTermSettings(fileno(stdin), (void*) &initial_settings); 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) void clean_up_and_die(int sig)

View File

@ -173,7 +173,7 @@ extern int dd_main(int argc, char **argv)
cleanup: cleanup:
/* Note that we are not freeing memory or closing /* Note that we are not freeing memory or closing
* files here, to save a few bytes. */ * files here, to save a few bytes. */
#if 0 #ifdef BB_FEATURE_CLEAN_UP
close(inFd); close(inFd);
close(outFd); close(outFd);
free(buf); free(buf);

2
dd.c
View File

@ -173,7 +173,7 @@ extern int dd_main(int argc, char **argv)
cleanup: cleanup:
/* Note that we are not freeing memory or closing /* Note that we are not freeing memory or closing
* files here, to save a few bytes. */ * files here, to save a few bytes. */
#if 0 #ifdef BB_FEATURE_CLEAN_UP
close(inFd); close(inFd);
close(outFd); close(outFd);
free(buf); free(buf);

View 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? */ /*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() static void destroy_cmd_strs()
{ {
if (sed_cmds == NULL) if (sed_cmds == NULL)
@ -663,7 +663,7 @@ extern int sed_main(int argc, char **argv)
{ {
int opt; int opt;
#if 0 #ifdef BB_FEATURE_CLEAN_UP
/* destroy command strings on exit */ /* destroy command strings on exit */
if (atexit(destroy_cmd_strs) == -1) { if (atexit(destroy_cmd_strs) == -1) {
perror("sed"); perror("sed");

View File

@ -1319,7 +1319,7 @@ static void alloc_name_list(void)
name_list[i] = xmalloc(sizeof(char) * BUFSIZ + 1); name_list[i] = xmalloc(sizeof(char) * BUFSIZ + 1);
} }
#if 0 #ifdef BB_FEATURE_CLEAN_UP
/* execute this atexit() to deallocate name_list[] */ /* execute this atexit() to deallocate name_list[] */
/* piptigger was here */ /* piptigger was here */
static void free_name_list(void) static void free_name_list(void)
@ -1344,9 +1344,11 @@ extern int fsck_minix_main(int argc, char **argv)
int retcode = 0; int retcode = 0;
alloc_name_list(); alloc_name_list();
#ifdef BB_FEATURE_CLEAN_UP
/* Don't bother to free memory. Exit does /* Don't bother to free memory. Exit does
* that automagically, so we can save a few bytes */ * 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) if (INODE_SIZE * MINIX_INODES_PER_BLOCK != BLOCK_SIZE)
die("bad inode size"); die("bad inode size");

View File

@ -347,9 +347,9 @@ extern int mount_main(int argc, char **argv)
mntentlist[i].mnt_opts, mntentlist[i].mnt_freq, mntentlist[i].mnt_opts, mntentlist[i].mnt_freq,
mntentlist[i].mnt_passno); mntentlist[i].mnt_passno);
} }
#ifdef BB_FEATURE_CLEAN_UP
/* Don't bother to close files or free memory. Exit /* Don't bother to close files or free memory. Exit
* does that automagically, so we can save a few bytes */ * does that automagically, so we can save a few bytes */
#if 0
free( mntentlist); free( mntentlist);
close(fd); close(fd);
#endif #endif

4
sed.c
View 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? */ /*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() static void destroy_cmd_strs()
{ {
if (sed_cmds == NULL) if (sed_cmds == NULL)
@ -663,7 +663,7 @@ extern int sed_main(int argc, char **argv)
{ {
int opt; int opt;
#if 0 #ifdef BB_FEATURE_CLEAN_UP
/* destroy command strings on exit */ /* destroy command strings on exit */
if (atexit(destroy_cmd_strs) == -1) { if (atexit(destroy_cmd_strs) == -1) {
perror("sed"); perror("sed");

View File

@ -115,6 +115,18 @@ void cmdedit_reset_term(void)
if (reset_term) if (reset_term)
/* sparc and other have broken termios support: use old termio handling. */ /* sparc and other have broken termios support: use old termio handling. */
setTermSettings(fileno(stdin), (void*) &initial_settings); 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) void clean_up_and_die(int sig)

View File

@ -142,7 +142,7 @@ char *mtab_next(void **iter)
/* Don't bother to clean up, since exit() does that /* Don't bother to clean up, since exit() does that
* automagically, so we can save a few bytes */ * automagically, so we can save a few bytes */
#if 0 #ifdef BB_FEATURE_CLEAN_UP
void mtab_free(void) void mtab_free(void)
{ {
struct _mtab_entry_t *this, *next; struct _mtab_entry_t *this, *next;
@ -235,6 +235,9 @@ extern int umount_main(int argc, char **argv)
if (argc < 2) { if (argc < 2) {
usage(umount_usage); usage(umount_usage);
} }
#ifdef BB_FEATURE_CLEAN_UP
atexit(mtab_free);
#endif
/* Parse any options */ /* Parse any options */
while (--argc > 0 && **(++argv) == '-') { while (--argc > 0 && **(++argv) == '-') {

View File

@ -1319,7 +1319,7 @@ static void alloc_name_list(void)
name_list[i] = xmalloc(sizeof(char) * BUFSIZ + 1); name_list[i] = xmalloc(sizeof(char) * BUFSIZ + 1);
} }
#if 0 #ifdef BB_FEATURE_CLEAN_UP
/* execute this atexit() to deallocate name_list[] */ /* execute this atexit() to deallocate name_list[] */
/* piptigger was here */ /* piptigger was here */
static void free_name_list(void) static void free_name_list(void)
@ -1344,9 +1344,11 @@ extern int fsck_minix_main(int argc, char **argv)
int retcode = 0; int retcode = 0;
alloc_name_list(); alloc_name_list();
#ifdef BB_FEATURE_CLEAN_UP
/* Don't bother to free memory. Exit does /* Don't bother to free memory. Exit does
* that automagically, so we can save a few bytes */ * 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) if (INODE_SIZE * MINIX_INODES_PER_BLOCK != BLOCK_SIZE)
die("bad inode size"); die("bad inode size");

View File

@ -347,9 +347,9 @@ extern int mount_main(int argc, char **argv)
mntentlist[i].mnt_opts, mntentlist[i].mnt_freq, mntentlist[i].mnt_opts, mntentlist[i].mnt_freq,
mntentlist[i].mnt_passno); mntentlist[i].mnt_passno);
} }
#ifdef BB_FEATURE_CLEAN_UP
/* Don't bother to close files or free memory. Exit /* Don't bother to close files or free memory. Exit
* does that automagically, so we can save a few bytes */ * does that automagically, so we can save a few bytes */
#if 0
free( mntentlist); free( mntentlist);
close(fd); close(fd);
#endif #endif

View File

@ -142,7 +142,7 @@ char *mtab_next(void **iter)
/* Don't bother to clean up, since exit() does that /* Don't bother to clean up, since exit() does that
* automagically, so we can save a few bytes */ * automagically, so we can save a few bytes */
#if 0 #ifdef BB_FEATURE_CLEAN_UP
void mtab_free(void) void mtab_free(void)
{ {
struct _mtab_entry_t *this, *next; struct _mtab_entry_t *this, *next;
@ -235,6 +235,9 @@ extern int umount_main(int argc, char **argv)
if (argc < 2) { if (argc < 2) {
usage(umount_usage); usage(umount_usage);
} }
#ifdef BB_FEATURE_CLEAN_UP
atexit(mtab_free);
#endif
/* Parse any options */ /* Parse any options */
while (--argc > 0 && **(++argv) == '-') { while (--argc > 0 && **(++argv) == '-') {