Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(683)

Unified Diff: runtime/vm/os_macos.cc

Issue 1989513002: strnlen is not always available. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/os_macos.cc
diff --git a/runtime/vm/os_macos.cc b/runtime/vm/os_macos.cc
index 6d2d02ac1ffdb59bd3233aa9023d7d43e465a786..07a767516f3acf4c90714a403d60bb170658689c 100644
--- a/runtime/vm/os_macos.cc
+++ b/runtime/vm/os_macos.cc
@@ -279,6 +279,23 @@ char* OS::StrNDup(const char* s, intptr_t n) {
}
+intptr_t OS::StrNLen(const char* s, intptr_t n) {
+ // strnlen has only been added to Mac OS X in 10.7. We are supplying
+ // our own copy here if needed.
+#if !defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || \
+ __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ <= 1060
+ intptr_t len = 0;
+ while ((len <= n) && (*s != '\0')) {
+ s++;
+ len++;
+ }
+ return len;
+#else // !defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || ...
+ return strnlen(s, n);
+#endif // !defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || ...
+}
+
+
void OS::Print(const char* format, ...) {
#if TARGET_OS_IOS
va_list args;
« no previous file with comments | « runtime/vm/os_linux.cc ('k') | runtime/vm/os_win.cc » ('j') | runtime/vm/os_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698