Chromium Code Reviews| Index: native_client_sdk/src/libraries/nacl_io/kernel_object.cc |
| diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_object.cc b/native_client_sdk/src/libraries/nacl_io/kernel_object.cc |
| index 8c670f8f789f89dc91cf41755e817dc351a1c3d2..93b2f9a1d5b072e82bb110812a84876a8480a122 100644 |
| --- a/native_client_sdk/src/libraries/nacl_io/kernel_object.cc |
| +++ b/native_client_sdk/src/libraries/nacl_io/kernel_object.cc |
| @@ -253,8 +253,15 @@ void KernelObject::FreeAndReassignFD(int fd, |
| AUTO_LOCK(handle_lock_); |
| // If the required FD is larger than the current set, grow the set |
| - if (fd >= (int)handle_map_.size()) |
| + if (fd >= (int)handle_map_.size()) { |
|
binji
2014/12/12 18:55:20
use c++-style cast
bradn
2014/12/12 22:58:18
Done.
|
| + int sz = (int)handle_map_.size(); |
|
Sam Clegg
2014/12/12 00:44:40
Move this line outside the condition to avoid call
bradn
2014/12/12 22:58:18
Done.
|
| handle_map_.resize(fd + 1); |
|
Sam Clegg
2014/12/12 00:44:40
A comment here to describe what is happening and w
bradn
2014/12/12 22:58:18
Done.
|
| + for (; sz < fd; ++sz) { |
| + free_fds_.push_back(sz); |
| + std::push_heap(free_fds_.begin(), free_fds_.end(), |
| + std::greater<int>()); |
| + } |
| + } |
| // This path will be from an existing handle, and absolute. |
| handle_map_[fd] = Descriptor_t(handle, path); |