From 7d1ba6b066cee563e1b52f712146bd2b322ef2ef Mon Sep 17 00:00:00 2001 From: Christian Menges Date: Sun, 9 May 2021 12:12:01 +0200 Subject: Fix memory leaks in examples (#604) --- example/passthrough_ll.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'example/passthrough_ll.c') diff --git a/example/passthrough_ll.c b/example/passthrough_ll.c index 0e7535c..8fdf887 100644 --- a/example/passthrough_ll.c +++ b/example/passthrough_ll.c @@ -171,6 +171,17 @@ static void lo_init(void *userdata, } } +static void lo_destroy(void *userdata) +{ + struct lo_data *lo = (struct lo_data*) userdata; + + while (lo->root.next != &lo->root) { + struct lo_inode* next = lo->root.next; + lo->root.next = next->next; + free(next); + } +} + static void lo_getattr(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi) { @@ -1113,6 +1124,7 @@ static void lo_lseek(fuse_req_t req, fuse_ino_t ino, off_t off, int whence, static const struct fuse_lowlevel_ops lo_oper = { .init = lo_init, + .destroy = lo_destroy, .lookup = lo_lookup, .mkdir = lo_mkdir, .mknod = lo_mknod, -- cgit v1.2.3