* 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.
+2013-07-09 Pádraig Brady <P@draigBrady.com>
+
+ 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 <eggert@cs.ucla.edu>
stdalign, verify: port to FreeBSD 9.1, to C11, and to C++11
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;
}
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);
+}
};
struct mount_entry *read_file_system_list (bool need_fs_type);
+void free_mount_entry (struct mount_entry *entry);
#endif