From 26d0c0aefde9a94f29d9850514fcbcf638eb8728 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 21 Aug 2013 12:31:43 +0200 Subject: libmount: add reference counting to libmount_fs * mnt_new_fs() returns object with refcount=1 * mnt_free_fs() does not care about reference counter * new functions mnt_ref_fs() and mnt_unref_fs() * mnt_table_add_fs() and mnt_table_rem_fs() uses reference counter * libmmnt_context uses reference counter for internal FS (as it could be shared outside the context) * backwardly incompatible change: - FS could be deallocated after mnt_table_remove_fs() * it's recommended to use mnt_unref_fs() after mnt_table_add_fs() Signed-off-by: Karel Zak --- libmount/src/tab_parse.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libmount/src/tab_parse.c') diff --git a/libmount/src/tab_parse.c b/libmount/src/tab_parse.c index 24e84457e..e31dac8c2 100644 --- a/libmount/src/tab_parse.c +++ b/libmount/src/tab_parse.c @@ -630,8 +630,9 @@ int mnt_table_parse_stream(struct libmnt_table *tb, FILE *f, const char *filenam if (rc == 0 && tb->fmt == MNT_FMT_MOUNTINFO) rc = kernel_fs_postparse(tb, fs, &tid, filename); } + mnt_unref_fs(fs); + if (rc) { - mnt_free_fs(fs); if (rc == 1) continue; /* recoverable error */ if (feof(f)) -- cgit v1.2.3-55-g7522