# HG changeset patch
# User Pádraig Brady
# Date 1373374558 -3600
# Node ID 26d088358005d51d4b61273f0fb5ce7a43ff7438
# Parent 897fb6ccfff341a15ad3d8fa1df0be207797b656
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.
diff -r 897fb6ccfff3 -r 26d088358005 ChangeLog
--- a/ChangeLog Sun Jul 07 23:06:26 2013 -0700
+++ b/ChangeLog Tue Jul 09 13:55:58 2013 +0100
@@ -1,3 +1,11 @@
+2013-07-09 Pádraig Brady
+
+ mountlist: add support for deallocating returned list entries
+ * lib/mountlist.c (free_mount_entry): A new exported function
+ to deallocate a mount list entry.
+ (read_file_system_list): Refactor to use the new deallocation function.
+ Suggested by Anton Ovchinnikov.
+
2013-07-07 Paul Eggert
stdalign, verify: port to FreeBSD 9.1, to C11, and to C++11
diff -r 897fb6ccfff3 -r 26d088358005 lib/mountlist.c
--- a/lib/mountlist.c Sun Jul 07 23:06:26 2013 -0700
+++ b/lib/mountlist.c Tue Jul 09 13:55:58 2013 +0100
@@ -961,11 +961,7 @@
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 @@
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 -r 897fb6ccfff3 -r 26d088358005 lib/mountlist.h
--- a/lib/mountlist.h Sun Jul 07 23:06:26 2013 -0700
+++ b/lib/mountlist.h Tue Jul 09 13:55:58 2013 +0100
@@ -36,5 +36,6 @@
};
struct mount_entry *read_file_system_list (bool need_fs_type);
+void free_mount_entry (struct mount_entry *entry);
#endif