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

Unified Diff: runtime/vm/os_macos.cc

Issue 1331623002: Uses SNPRINT macro where possible. Otherwise uses #define for format. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Add back assembler functions Created 5 years, 3 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 efdcd2bbf937c479c903ddb901bce0a19a0f7592..febdab329cb4c305b92378403cf94ba7d7d85ea7 100644
--- a/runtime/vm/os_macos.cc
+++ b/runtime/vm/os_macos.cc
@@ -205,6 +205,34 @@ int OS::SNPrint(char* str, size_t size, const char* format, ...) {
}
+char* OS::SNCreate(Zone* zone, const char* format, ...) {
+ va_list args;
+ va_start(args, format);
+
+ // Measure.
+ va_list measure_args;
+ va_copy(measure_args, args);
+ intptr_t len = VSNPrint(NULL, 0, format, measure_args);
+ va_end(measure_args);
+
+ char* buffer;
+ if (zone) {
+ buffer = zone->Alloc<char>(len + 1);
+ } else {
+ buffer = reinterpret_cast<char*>(malloc(len + 1));
+ }
+ ASSERT(buffer != NULL);
+
+ // Print.
+ va_list print_args;
+ va_copy(print_args, args);
+ VSNPrint(buffer, len + 1, format, print_args);
+ va_end(print_args);
+ va_end(args);
+ return buffer;
+}
+
+
int OS::VSNPrint(char* str, size_t size, const char* format, va_list args) {
int retval = vsnprintf(str, size, format, args);
if (retval < 0) {
« runtime/vm/os_android.cc ('K') | « runtime/vm/os_linux.cc ('k') | runtime/vm/os_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698