Message ID | cover.1725386993.git.loemra.dev@gmail.com (mailing list archive) |
---|---|
Headers | show |
Series | btrfs path auto free | expand |
On Tue, Sep 03, 2024 at 11:19:04AM -0700, Leo Martins wrote: > CHANGELOG: > Patch 1/3 > - Move BTRFS_PATH_AUTO_FREE macro definition next to btrfs_path > struct. > > The DEFINE_FREE macro defines a wrapper function for a given memory > cleanup function which takes a pointer as an argument and calls the > cleanup function with the value of the pointer. The __free macro adds > a scoped-based cleanup to a variable, using the __cleanup attribute > to specify the cleanup function that should be called when the variable > goes out of scope. > > Using this cleanup code pattern ensures that memory is properly freed > when it's no longer needed, preventing memory leaks and reducing the > risk of crashes or other issues caused by incorrect memory management. > Even if the code is already memory safe, using this pattern reduces > the risk of introducing memory-related bugs in the future > > In this series of patches I've added a DEFINE_FREE for btrfs_free_path > and created a macro BTRFS_PATH_AUTO_FREE to clearly identify path > declarations that will be automatically freed. > > I've included some simple examples of where this pattern can be used. > The trivial examples are ones where there is one exit path and the only > cleanup performed is a call to btrfs_free_path. > > Leo Martins (3): > btrfs: DEFINE_FREE for btrfs_free_path > btrfs: BTRFS_PATH_AUTO_FREE in zoned.c > btrfs: BTRFS_PATH_AUTO_FREE in orphan.c I've merged the series with some adjustments, we're short on time regarding the next merge window so we may not be able to do one more iteration with the fixes. Thanks.