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) if (!siz)
eprintf("grabmntinfo:"); eprintf("grabmntinfo:");
for (i = 0; i < siz; i++) for (i = 0; i < siz; i++) {
mnt_show(minfo[i].fsname, minfo[i].mntdir); mnt_show(minfo[i].fsname, minfo[i].mntdir);
free(minfo[i].fsname);
free(minfo[i].mntdir);
}
free(minfo); free(minfo);
return EXIT_SUCCESS; return EXIT_SUCCESS;

View File

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

View File

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

View File

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