• Leo Martins's avatar
    btrfs: DEFINE_FREE for struct btrfs_path · 4c74a32a
    Leo Martins authored
    Add a DEFINE_FREE for struct btrfs_path. This defines a function that
    can be called using the __free attribute. Define a macro
    BTRFS_PATH_AUTO_FREE to make the declaration of an auto freeing path
    very clear.
    
    The intended use is to define the auto free of path in cases where the
    path is allocated somewhere at the beginning and freed either on all
    error paths or at the end of the function.
    
      int func() {
    	  BTRFS_PATH_AUTO_FREE(path);
    
    	  if (...)
    		  return -ERROR;
    
    	  path = alloc_path();
    
    	  ...
    
    	  if (...)
    		  return -ERROR;
    
    	  ...
    	  return 0;
      }
    Signed-off-by: default avatarLeo Martins <loemra.dev@gmail.com>
    [ update changelog ]
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    4c74a32a
ctree.h 23.6 KB