Skip to content
Snippets Groups Projects
  • Colin Walters's avatar
    f5ba01cf
    dirfd: Have dfd iter _take_fd() take a pointer and do a steal · f5ba01cf
    Colin Walters authored
    This avoids callers having to use `glnx_steal_fd()` on their own; in general, I
    think we should implement move semantics like this at the callee level.
    
    Another reason to do this is there's a subtle problem with doing:
    
    ```
    somefunction (steal_value (&v), ..., error);
    ```
    
    in that if `somefunction` throws, it may not have taken ownership of the value.
    At least `glnx_dirfd_iterator_init_take_fd()` didn't.
    f5ba01cf
    History
    dirfd: Have dfd iter _take_fd() take a pointer and do a steal
    Colin Walters authored
    This avoids callers having to use `glnx_steal_fd()` on their own; in general, I
    think we should implement move semantics like this at the callee level.
    
    Another reason to do this is there's a subtle problem with doing:
    
    ```
    somefunction (steal_value (&v), ..., error);
    ```
    
    in that if `somefunction` throws, it may not have taken ownership of the value.
    At least `glnx_dirfd_iterator_init_take_fd()` didn't.