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

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 missing include 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
« no previous file with comments | « runtime/vm/os_macos.cc ('k') | runtime/vm/snapshot.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/os_win.cc
diff --git a/runtime/vm/os_win.cc b/runtime/vm/os_win.cc
index 1f66ad4a3fba206d9a329f34215286f1324cc556..85133418f1de562b9b26421541df1e7f68582824 100644
--- a/runtime/vm/os_win.cc
+++ b/runtime/vm/os_win.cc
@@ -15,6 +15,7 @@
#include "platform/assert.h"
#include "vm/os_thread.h"
#include "vm/vtune.h"
+#include "vm/zone.h"
namespace dart {
@@ -271,6 +272,39 @@ int OS::VSNPrint(char* str, size_t size, const char* format, va_list args) {
}
+char* OS::SCreate(Zone* zone, const char* format, ...) {
+ va_list args;
+ va_start(args, format);
+ char* buffer = VSCreate(zone, format, args);
+ va_end(args);
+ return buffer;
+}
+
+
+char* OS::VSCreate(Zone* zone, const char* format, va_list args) {
+ // 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);
+ return buffer;
+}
+
+
bool OS::StringToInt64(const char* str, int64_t* value) {
ASSERT(str != NULL && strlen(str) > 0 && value != NULL);
int32_t base = 10;
« no previous file with comments | « 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