Free minfo table

This commit is contained in:
sin 2014-01-25 22:34:05 +00:00
parent 4040857074
commit 5b0d03acc6
4 changed files with 15 additions and 3 deletions

5
df.c
View File

@ -35,8 +35,11 @@ main(int argc, char *argv[])
if (!siz)
eprintf("grabmntinfo:");
for (i = 0; i < siz; i++)
for (i = 0; i < siz; i++) {
mnt_show(minfo[i].fsname, minfo[i].mntdir);
free(minfo[i].fsname);
free(minfo[i].mntdir);
}
free(minfo);
return EXIT_SUCCESS;

View File

@ -1,8 +1,8 @@
/* See LICENSE file for copyright and license details. */
struct mntinfo {
const char *fsname;
const char *mntdir;
char *fsname;
char *mntdir;
};
int grabmntinfo(struct mntinfo **minfo);

View File

@ -149,6 +149,10 @@ main(int argc, char *argv[])
if (mount(source, target, types, flags, data) < 0)
eprintf("mount:");
for (i = 0; i < siz; i++) {
free(minfo[i].fsname);
free(minfo[i].mntdir);
}
free(minfo);
opt = opthead;

View File

@ -72,6 +72,11 @@ main(int argc, char *argv[])
st1.st_ino == st2.st_ino)
break;
}
for (i = 0; i < siz; i++) {
free(minfo[i].fsname);
free(minfo[i].mntdir);
}
free(minfo);
if (i == siz)