X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fmountlist.c;h=d59c9937f5d38d2ac239f11bb175ab6e5c3fa855;hb=a6ae1bb228f3bcfac76095600d05969d214ed65f;hp=d8d54646c11572d718d324da4c6b871efd89c13e;hpb=62bb7a8bf95807d6339e1e17fc0d21c319b280a2;p=gnulib.git diff --git a/lib/mountlist.c b/lib/mountlist.c index d8d54646c..d59c9937f 100644 --- a/lib/mountlist.c +++ b/lib/mountlist.c @@ -1,6 +1,6 @@ /* mountlist.c -- return a list of mounted file systems - Copyright (C) 1991-1992, 1997-2013 Free Software Foundation, Inc. + Copyright (C) 1991-1992, 1997-2014 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -946,6 +946,7 @@ read_file_system_list (bool need_fs_type) mtail = &me->me_next; } } + closedir (dirp); } #endif /* MOUNTED_INTERIX_STATVFS */ @@ -961,11 +962,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 +970,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); +}