libhammer - Add an overlooked function that releases snaps
authorAntonio Huete Jimenez <tuxillo@quantumachine.net>
Thu, 19 Feb 2015 13:14:29 +0000 (14:14 +0100)
committerAntonio Huete Jimenez <tuxillo@quantumachine.net>
Thu, 19 Feb 2015 14:26:17 +0000 (15:26 +0100)
- Add a function to release resources allocated for libhammer_pfs_get_snapshots.
- Release snapshot resources when releasing the fsinfo struct.

lib/libhammer/info.c
lib/libhammer/libhammer.h
lib/libhammer/snapshot.c

index 47e2ea7..7692192 100644 (file)
@@ -133,6 +133,7 @@ libhammer_free_fsinfo(libhammer_fsinfo_t fip)
 
        while(!TAILQ_EMPTY(&fip->list_pseudo)) {
                pfstmp = TAILQ_FIRST(&fip->list_pseudo);
+               libhammer_pfs_free_snapshots(pfstmp);
                if (pfstmp->mountedon)
                        free(pfstmp->mountedon);
                TAILQ_REMOVE(&fip->list_pseudo, pfstmp, entries);
index 6463b0d..a01901c 100644 (file)
@@ -177,6 +177,7 @@ int libhammer_btree_stats(struct libhammer_btree_stats *);
 int libhammer_io_stats(struct libhammer_io_stats *);
 
 int libhammer_pfs_get_snapshots(libhammer_fsinfo_t, libhammer_pfsinfo_t);
+void libhammer_pfs_free_snapshots(libhammer_pfsinfo_t);
 
 char *libhammer_find_pfs_mount(uuid_t *);
 void libhammer_pfs_canonical_path(char *, libhammer_pfsinfo_t, char **);
index 46d7ad9..1dc8f81 100644 (file)
@@ -117,3 +117,15 @@ out:
 
        return (ret);
 }
+
+void
+libhammer_pfs_free_snapshots(libhammer_pfsinfo_t pip)
+{
+       struct libhammer_snapinfo *si;
+
+       while(!TAILQ_EMPTY(&pip->list_snap)) {
+               si = TAILQ_FIRST(&pip->list_snap);
+               TAILQ_REMOVE(&pip->list_snap, si, entries);
+               free(si);
+       }
+}