From: Darrick J. Wong Date: Wed, 6 Dec 2017 15:17:08 +0000 (-0600) Subject: libhandle: add missing destructor X-Git-Tag: v4.15.0-rc1~126 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=852fe0131d1647bb89cf6d894348091d8a8c68be;p=thirdparty%2Fxfsprogs-dev.git libhandle: add missing destructor Make it so that we can tear down the file descriptor hash table. Signed-off-by: Darrick J. Wong Reviewed-by: Eric Sandeen Signed-off-by: Eric Sandeen --- diff --git a/include/handle.h b/include/handle.h index ee69a11da..49f14410c 100644 --- a/include/handle.h +++ b/include/handle.h @@ -50,6 +50,8 @@ extern int parentpaths_by_handle(void *__hanp, size_t __hlen, extern int fssetdm_by_handle (void *__hanp, size_t __hlen, struct fsdmidata *__fsdmi); +void fshandle_destroy(void); + #ifdef __cplusplus } #endif diff --git a/libhandle/handle.c b/libhandle/handle.c index 00127b3c3..e6971dd30 100644 --- a/libhandle/handle.c +++ b/libhandle/handle.c @@ -62,6 +62,19 @@ struct fdhash { static struct fdhash *fdhash_head = NULL; +void +fshandle_destroy(void) +{ + struct fdhash *nexth; + struct fdhash *h = fdhash_head; + + while (h) { + nexth = h->fnxt; + free(h); + h = nexth; + } +} + int path_to_fshandle( char *path, /* input, path to convert */