Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "broker_process_utils.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 | |
| 9 namespace sandbox { | |
| 10 | |
| 11 const char* BrokerProcessUtils::Find( | |
|
jln (very slow on Chromium)
2013/07/08 22:36:51
If this is not really guaranteed async signal safe
Jorge Lucangeli Obes
2013/07/09 03:52:12
Done, but I don't understand why this would not re
| |
| 12 const char* needle, | |
| 13 const std::vector<std::string>& haystack) { | |
| 14 std::vector<std::string>::const_iterator it; | |
| 15 | |
| 16 for (it = haystack.begin(); it != haystack.end(); it++) { | |
| 17 if (StrCmp(needle, it->c_str()) == 0) | |
| 18 return it->c_str(); | |
| 19 } | |
| 20 | |
| 21 return NULL; | |
| 22 } | |
| 23 | |
| 24 int BrokerProcessUtils::StrCmp(const char* s1, const char* s2) { | |
|
jln (very slow on Chromium)
2013/07/08 22:36:51
As mentioned, this really needs unit tests.
Pleas
| |
| 25 while (*s1 != '\0' && *s2 != '\0') { | |
| 26 if (*s1 < *s2) | |
| 27 return -1; | |
| 28 else if (*s1 > *s2) | |
| 29 return 1; | |
| 30 | |
| 31 s1++; | |
| 32 s2++; | |
| 33 } | |
| 34 | |
| 35 if (*s1 == '\0' && *s2 == '\0') | |
|
jln (very slow on Chromium)
2013/07/08 22:36:51
Style: use brackets everywhere if you use them in
Jorge Lucangeli Obes
2013/07/09 03:52:12
Done.
| |
| 36 return 0; | |
| 37 else if (*s1 == '\0') | |
| 38 return -1; | |
| 39 else if (*s2 == '\0') | |
| 40 return 1; | |
| 41 else { | |
| 42 NOTREACHED(); | |
|
jln (very slow on Chromium)
2013/07/08 22:36:51
This is not async signal safe. Use RAW_CHECK (in !
Jorge Lucangeli Obes
2013/07/09 03:52:12
Done.
| |
| 43 return 0; | |
|
jln (very slow on Chromium)
2013/07/08 22:36:51
GCC is still dumb enough to not see this dead code
Jorge Lucangeli Obes
2013/07/09 03:52:12
Done.
| |
| 44 } | |
| 45 } | |
| 46 | |
| 47 } // namespace sandbox | |
| OLD | NEW |