summaryrefslogtreecommitdiff
path: root/core/fs
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2010-06-26 18:46:33 -0700
committerH. Peter Anvin <hpa@zytor.com>2010-06-26 18:46:33 -0700
commit17a32fe2e902d7d65b2f6aa3f501456662d53fc4 (patch)
treeaf211658cc86c12374004718dad59b0801c626b0 /core/fs
parent6d3918a893e83267342ebd6b7d5c03cad4f27635 (diff)
downloadsyslinux-17a32fe2e902d7d65b2f6aa3f501456662d53fc4.tar.gz
core, fs: eliminate recursion in put_inode()
We don't actually need recursion in put_inode(), so replace recursion with a loop. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'core/fs')
-rw-r--r--core/fs/fs.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/core/fs/fs.c b/core/fs/fs.c
index a101dfda..48856c9e 100644
--- a/core/fs/fs.c
+++ b/core/fs/fs.c
@@ -34,11 +34,10 @@ struct inode *alloc_inode(struct fs_info *fs, uint32_t ino, size_t data)
*/
void put_inode(struct inode *inode)
{
- if (inode) {
- if (! --inode->refcnt) {
- put_inode(inode->parent);
- free(inode);
- }
+ while (inode && --inode->refcnt == 0) {
+ struct inode *dead = inode;
+ inode = inode->parent;
+ free(dead);
}
}