diff options
Diffstat (limited to 'e2fsprogs/ext2fs/freefs.c')
-rw-r--r-- | e2fsprogs/ext2fs/freefs.c | 52 |
1 files changed, 16 insertions, 36 deletions
diff --git a/e2fsprogs/ext2fs/freefs.c b/e2fsprogs/ext2fs/freefs.c index 3fd51f257..f0f7b3eec 100644 --- a/e2fsprogs/ext2fs/freefs.c +++ b/e2fsprogs/ext2fs/freefs.c | |||
@@ -30,25 +30,17 @@ void ext2fs_free(ext2_filsys fs) | |||
30 | if (fs->io) { | 30 | if (fs->io) { |
31 | io_channel_close(fs->io); | 31 | io_channel_close(fs->io); |
32 | } | 32 | } |
33 | if (fs->device_name) | 33 | ext2fs_free_mem(&fs->device_name); |
34 | ext2fs_free_mem(&fs->device_name); | 34 | ext2fs_free_mem(&fs->super); |
35 | if (fs->super) | 35 | ext2fs_free_mem(&fs->orig_super); |
36 | ext2fs_free_mem(&fs->super); | 36 | ext2fs_free_mem(&fs->group_desc); |
37 | if (fs->orig_super) | 37 | ext2fs_free_block_bitmap(fs->block_map); |
38 | ext2fs_free_mem(&fs->orig_super); | 38 | ext2fs_free_inode_bitmap(fs->inode_map); |
39 | if (fs->group_desc) | 39 | |
40 | ext2fs_free_mem(&fs->group_desc); | 40 | ext2fs_badblocks_list_free(fs->badblocks); |
41 | if (fs->block_map) | ||
42 | ext2fs_free_block_bitmap(fs->block_map); | ||
43 | if (fs->inode_map) | ||
44 | ext2fs_free_inode_bitmap(fs->inode_map); | ||
45 | |||
46 | if (fs->badblocks) | ||
47 | ext2fs_badblocks_list_free(fs->badblocks); | ||
48 | fs->badblocks = 0; | 41 | fs->badblocks = 0; |
49 | 42 | ||
50 | if (fs->dblist) | 43 | ext2fs_free_dblist(fs->dblist); |
51 | ext2fs_free_dblist(fs->dblist); | ||
52 | 44 | ||
53 | if (fs->icache) | 45 | if (fs->icache) |
54 | ext2fs_free_inode_cache(fs->icache); | 46 | ext2fs_free_inode_cache(fs->icache); |
@@ -64,14 +56,8 @@ void ext2fs_free_generic_bitmap(ext2fs_inode_bitmap bitmap) | |||
64 | return; | 56 | return; |
65 | 57 | ||
66 | bitmap->magic = 0; | 58 | bitmap->magic = 0; |
67 | if (bitmap->description) { | 59 | ext2fs_free_mem(&bitmap->description); |
68 | ext2fs_free_mem(&bitmap->description); | 60 | ext2fs_free_mem(&bitmap->bitmap); |
69 | bitmap->description = 0; | ||
70 | } | ||
71 | if (bitmap->bitmap) { | ||
72 | ext2fs_free_mem(&bitmap->bitmap); | ||
73 | bitmap->bitmap = 0; | ||
74 | } | ||
75 | ext2fs_free_mem(&bitmap); | 61 | ext2fs_free_mem(&bitmap); |
76 | } | 62 | } |
77 | 63 | ||
@@ -100,10 +86,8 @@ static void ext2fs_free_inode_cache(struct ext2_inode_cache *icache) | |||
100 | { | 86 | { |
101 | if (--icache->refcount) | 87 | if (--icache->refcount) |
102 | return; | 88 | return; |
103 | if (icache->buffer) | 89 | ext2fs_free_mem(&icache->buffer); |
104 | ext2fs_free_mem(&icache->buffer); | 90 | ext2fs_free_mem(&icache->cache); |
105 | if (icache->cache) | ||
106 | ext2fs_free_mem(&icache->cache); | ||
107 | icache->buffer_blk = 0; | 91 | icache->buffer_blk = 0; |
108 | ext2fs_free_mem(&icache); | 92 | ext2fs_free_mem(&icache); |
109 | } | 93 | } |
@@ -113,12 +97,10 @@ static void ext2fs_free_inode_cache(struct ext2_inode_cache *icache) | |||
113 | */ | 97 | */ |
114 | void ext2fs_u32_list_free(ext2_u32_list bb) | 98 | void ext2fs_u32_list_free(ext2_u32_list bb) |
115 | { | 99 | { |
116 | if (bb->magic != EXT2_ET_MAGIC_BADBLOCKS_LIST) | 100 | if (!bb || bb->magic != EXT2_ET_MAGIC_BADBLOCKS_LIST) |
117 | return; | 101 | return; |
118 | 102 | ||
119 | if (bb->list) | 103 | ext2fs_free_mem(&bb->list); |
120 | ext2fs_free_mem(&bb->list); | ||
121 | bb->list = 0; | ||
122 | ext2fs_free_mem(&bb); | 104 | ext2fs_free_mem(&bb); |
123 | } | 105 | } |
124 | 106 | ||
@@ -136,9 +118,7 @@ void ext2fs_free_dblist(ext2_dblist dblist) | |||
136 | if (!dblist || (dblist->magic != EXT2_ET_MAGIC_DBLIST)) | 118 | if (!dblist || (dblist->magic != EXT2_ET_MAGIC_DBLIST)) |
137 | return; | 119 | return; |
138 | 120 | ||
139 | if (dblist->list) | 121 | ext2fs_free_mem(&dblist->list); |
140 | ext2fs_free_mem(&dblist->list); | ||
141 | dblist->list = 0; | ||
142 | if (dblist->fs && dblist->fs->dblist == dblist) | 122 | if (dblist->fs && dblist->fs->dblist == dblist) |
143 | dblist->fs->dblist = 0; | 123 | dblist->fs->dblist = 0; |
144 | dblist->magic = 0; | 124 | dblist->magic = 0; |