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

Unified Diff: runtime/vm/os_win.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_win.cc
diff --git a/runtime/vm/os_win.cc b/runtime/vm/os_win.cc
index 1f66ad4a3fba206d9a329f34215286f1324cc556..ea0460a10865d89b9520fe48024f478821b3a086 100644
--- a/runtime/vm/os_win.cc
+++ b/runtime/vm/os_win.cc
@@ -236,6 +236,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) {
if (str == NULL || size == 0) {
int retval = _vscprintf(format, args);
« runtime/vm/os_android.cc ('K') | « runtime/vm/os_macos.cc ('k') | runtime/vm/snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698