Oops. Forgot the usleep.c file.
[oweals/busybox.git] / fsck_minix.c
index cfa973ecf321cbc3401f45c344d8e55db794f176..aa0a82432c6a85c3717955876a1746abcc84bb2f 100644 (file)
@@ -603,23 +603,13 @@ static void read_superblock(void)
 
 static void read_tables(void)
 {
-       inode_map = malloc(IMAPS * BLOCK_SIZE);
-       if (!inode_map)
-               die("Unable to allocate buffer for inode map");
-       zone_map = malloc(ZMAPS * BLOCK_SIZE);
-       if (!inode_map)
-               die("Unable to allocate buffer for zone map");
+       inode_map = xmalloc(IMAPS * BLOCK_SIZE);
+       zone_map = xmalloc(ZMAPS * BLOCK_SIZE);
        memset(inode_map, 0, sizeof(inode_map));
        memset(zone_map, 0, sizeof(zone_map));
-       inode_buffer = malloc(INODE_BUFFER_SIZE);
-       if (!inode_buffer)
-               die("Unable to allocate buffer for inodes");
-       inode_count = malloc(INODES + 1);
-       if (!inode_count)
-               die("Unable to allocate buffer for inode count");
-       zone_count = malloc(ZONES);
-       if (!zone_count)
-               die("Unable to allocate buffer for zone count");
+       inode_buffer = xmalloc(INODE_BUFFER_SIZE);
+       inode_count = xmalloc(INODES + 1);
+       zone_count = xmalloc(ZONES);
        if (IMAPS * BLOCK_SIZE != read(IN, inode_map, IMAPS * BLOCK_SIZE))
                die("Unable to read inode map");
        if (ZMAPS * BLOCK_SIZE != read(IN, zone_map, ZMAPS * BLOCK_SIZE))
@@ -1247,20 +1237,12 @@ static void alloc_name_list(void)
 {
        int i;
 
-       name_list = malloc(sizeof(char *) * MAX_DEPTH);
-       if (!name_list) { 
-               fprintf(stderr,"fsck_minix: name_list: %s\n", strerror(errno));
-               exit(1); 
-       }
-       for (i = 0; i < MAX_DEPTH; i++) {
-               name_list[i] = malloc(sizeof(char) * PATH_MAX + 1);
-               if (!name_list[i]) {
-                       fprintf(stderr,"fsck_minix: name_list: %s\n", strerror(errno));
-                       exit(1); 
-               }
-       }
+       name_list = xmalloc(sizeof(char *) * MAX_DEPTH);
+       for (i = 0; i < MAX_DEPTH; i++)
+               name_list[i] = xmalloc(sizeof(char) * PATH_MAX + 1);
 }
 
+#if 0
 /* execute this atexit() to deallocate name_list[] */
 /* piptigger was here */
 static void free_name_list(void)
@@ -1276,6 +1258,7 @@ static void free_name_list(void)
                free(name_list);
        }
 }
+#endif
 
 extern int fsck_minix_main(int argc, char **argv)
 {
@@ -1284,7 +1267,9 @@ extern int fsck_minix_main(int argc, char **argv)
        int retcode = 0;
 
        alloc_name_list();
-       atexit(free_name_list);
+       /* Don't bother to free memory.  Exit does
+        * that automagically, so we can save a few bytes */
+       //atexit(free_name_list);
 
        if (argc && *argv)
                program_name = *argv;