summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2013-07-09 13:55:58 +0100
committerPádraig Brady <P@draigBrady.com>2013-07-09 13:55:58 +0100
commit41d1b6c42641a5b9e21486ca2074198ee7909bd7 (patch)
tree31c712b1f9e49cd6cbc55a8e3552918753c8e725 /lib
parent848529bafe96b53d3a52af546aeb04bae1bd35d5 (diff)
downloadgnulib-41d1b6c42641a5b9e21486ca2074198ee7909bd7.tar.gz
mountlist: add support for deallocating returned list entries
* lib/mountlist.c (free_mount_entry): A new exported function to deallocate a mount list entry. * lib/mountlist.h: Declare the new function. (read_file_system_list): Refactor to use the new deallocation function. Suggested by Anton Ovchinnikov.
Diffstat (limited to 'lib')
-rw-r--r--lib/mountlist.c17
-rw-r--r--lib/mountlist.h1
2 files changed, 13 insertions, 5 deletions
diff --git a/lib/mountlist.c b/lib/mountlist.c
index d8d54646c1..30f4286130 100644
--- a/lib/mountlist.c
+++ b/lib/mountlist.c
@@ -961,11 +961,7 @@ read_file_system_list (bool need_fs_type)
while (mount_list)
{
me = mount_list->me_next;
- free (mount_list->me_devname);
- free (mount_list->me_mountdir);
- if (mount_list->me_type_malloced)
- free (mount_list->me_type);
- free (mount_list);
+ free_mount_entry (mount_list);
mount_list = me;
}
@@ -973,3 +969,14 @@ read_file_system_list (bool need_fs_type)
return NULL;
}
}
+
+/* Free a mount entry as returned from read_file_system_list (). */
+
+void free_mount_entry (struct mount_entry *me)
+{
+ free (me->me_devname);
+ free (me->me_mountdir);
+ if (me->me_type_malloced)
+ free (me->me_type);
+ free (me);
+}
diff --git a/lib/mountlist.h b/lib/mountlist.h
index ffdcc02b1a..55877e2399 100644
--- a/lib/mountlist.h
+++ b/lib/mountlist.h
@@ -36,5 +36,6 @@ struct mount_entry
};
struct mount_entry *read_file_system_list (bool need_fs_type);
+void free_mount_entry (struct mount_entry *entry);
#endif