summaryrefslogtreecommitdiff
path: root/util-linux/fsck_minix.c
diff options
context:
space:
mode:
authorErik Andersen2000-03-21 22:32:57 +0000
committerErik Andersen2000-03-21 22:32:57 +0000
commit0d068a20676144e9fd6796cc77764c420d785394 (patch)
treeaf12b114d51e9ae7a8753baf09feb9ab8d654f26 /util-linux/fsck_minix.c
parentc053e41fa0524d828bf90f47e5e3637b8facaadc (diff)
downloadbusybox-0d068a20676144e9fd6796cc77764c420d785394.zip
busybox-0d068a20676144e9fd6796cc77764c420d785394.tar.gz
* all mallocs now use xmalloc (and so are OOM error safe), and
the common error handling saves a few bytes. Thanks to Bob Tinsley <bob@earthrise.demon.co.uk> for the patch. -Erik
Diffstat (limited to 'util-linux/fsck_minix.c')
-rw-r--r--util-linux/fsck_minix.c35
1 files changed, 8 insertions, 27 deletions
diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c
index cfa973e..47e81ce 100644
--- a/util-linux/fsck_minix.c
+++ b/util-linux/fsck_minix.c
@@ -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,18 +1237,9 @@ 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);
}
/* execute this atexit() to deallocate name_list[] */