OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <dirent.h> | 5 #include <dirent.h> |
6 #include <errno.h> | 6 #include <errno.h> |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <signal.h> | 8 #include <signal.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <sys/resource.h> | 10 #include <sys/resource.h> |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 | 393 |
394 // if found, we'll either be deleting or replacing this element. | 394 // if found, we'll either be deleting or replacing this element. |
395 if (found) { | 395 if (found) { |
396 count--; | 396 count--; |
397 size -= strlen(pair) + 1; | 397 size -= strlen(pair) + 1; |
398 if (j->second.size()) | 398 if (j->second.size()) |
399 found = false; | 399 found = false; |
400 } | 400 } |
401 | 401 |
402 // if !found, then we have a new element to add. | 402 // if !found, then we have a new element to add. |
403 if (!found && j->second.size() > 0) { | 403 if (!found && !j->second.empty()) { |
404 count++; | 404 count++; |
405 size += j->first.size() + 1 /* '=' */ + j->second.size() + 1 /* NUL */; | 405 size += j->first.size() + 1 /* '=' */ + j->second.size() + 1 /* NUL */; |
406 } | 406 } |
407 } | 407 } |
408 | 408 |
409 count++; // for the final NULL | 409 count++; // for the final NULL |
410 uint8_t *buffer = new uint8_t[sizeof(char*) * count + size]; | 410 uint8_t *buffer = new uint8_t[sizeof(char*) * count + size]; |
411 char **const ret = reinterpret_cast<char**>(buffer); | 411 char **const ret = reinterpret_cast<char**>(buffer); |
412 unsigned k = 0; | 412 unsigned k = 0; |
413 char *scratch = reinterpret_cast<char*>(buffer + sizeof(char*) * count); | 413 char *scratch = reinterpret_cast<char*>(buffer + sizeof(char*) * count); |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 const ProcessFilter* filter) { | 981 const ProcessFilter* filter) { |
982 bool exited_cleanly = | 982 bool exited_cleanly = |
983 WaitForProcessesToExit(executable_name, wait_milliseconds, | 983 WaitForProcessesToExit(executable_name, wait_milliseconds, |
984 filter); | 984 filter); |
985 if (!exited_cleanly) | 985 if (!exited_cleanly) |
986 KillProcesses(executable_name, exit_code, filter); | 986 KillProcesses(executable_name, exit_code, filter); |
987 return exited_cleanly; | 987 return exited_cleanly; |
988 } | 988 } |
989 | 989 |
990 } // namespace base | 990 } // namespace base |
OLD | NEW |