* Registers fd with a currently unused number. If the table is full, * returns -ENFILE; */
| 74 | * returns -ENFILE; |
| 75 | */ |
| 76 | int OpenFd(const HandleT &handle) { |
| 77 | if (handle == invalid_handle_) |
| 78 | return -EINVAL; |
| 79 | if (fd_pivot_ >= fd_index_.size()) |
| 80 | return -ENFILE; |
| 81 | |
| 82 | size_t const next_fd = fd_index_[fd_pivot_]; |
| 83 | assert(next_fd < open_fds_.size()); |
| 84 | assert(open_fds_[next_fd].handle == invalid_handle_); |
| 85 | open_fds_[next_fd] = FdWrapper(handle, fd_pivot_); |
| 86 | ++fd_pivot_; |
| 87 | return next_fd; |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * For invalid and unused numbers, the invalid handle is returned. |
no test coverage detected