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

Side by Side Diff: runtime/vm/os_win.cc

Issue 10052030: Address review comments. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/os.h" 5 #include "vm/os.h"
6 6
7 #include <time.h> 7 #include <time.h>
8 8
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 10
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 153
154 int OS::SNPrint(char* str, size_t size, const char* format, ...) { 154 int OS::SNPrint(char* str, size_t size, const char* format, ...) {
155 va_list args; 155 va_list args;
156 va_start(args, format); 156 va_start(args, format);
157 int retval = VSNPrint(str, size, format, args); 157 int retval = VSNPrint(str, size, format, args);
158 va_end(args); 158 va_end(args);
159 return retval; 159 return retval;
160 } 160 }
161 161
162 162
163 // TODO(asiva): Consider moving this to "globals.h".
164 #ifndef va_copy
165 #define va_copy(dst, src) (memmove(&(dst), &(src), sizeof(dst)))
166 #endif /* va_copy */
167
168
163 int OS::VSNPrint(char* str, size_t size, const char* format, va_list args) { 169 int OS::VSNPrint(char* str, size_t size, const char* format, va_list args) {
164 if (str == NULL || size == 0) { 170 if (str == NULL || size == 0) {
165 return _vscprintf(format, args); 171 return _vscprintf(format, args);
166 } 172 }
167 int written =_vsnprintf(str, size, format, args); 173 va_list args_copy;
174 va_copy(args_copy, args);
175 int written =_vsnprintf(str, size, format, args_copy);
176 va_end(args_copy);
168 if (written < 0) { 177 if (written < 0) {
169 // _vsnprintf returns -1 if the number of characters to be written is 178 // _vsnprintf returns -1 if the number of characters to be written is
170 // larger than 'size', so we call _vscprintf which returns the number 179 // larger than 'size', so we call _vscprintf which returns the number
171 // of characters that would have been written. 180 // of characters that would have been written.
172 written = _vscprintf(format, args); 181 va_list args_retry;
182 va_copy(args_retry, args);
183 written = _vscprintf(format, args_retry);
184 va_end(args_retry);
173 } 185 }
174 // Make sure to zero-terminate the string if the output was 186 // Make sure to zero-terminate the string if the output was
175 // truncated or if there was an error. 187 // truncated or if there was an error.
176 if (written >= size) { 188 if (written >= size) {
177 str[size - 1] = '\0'; 189 str[size - 1] = '\0';
178 } 190 }
179 return written; 191 return written;
180 } 192 }
181 193
182 194
(...skipping 24 matching lines...) Expand all
207 void OS::Abort() { 219 void OS::Abort() {
208 abort(); 220 abort();
209 } 221 }
210 222
211 223
212 void OS::Exit(int code) { 224 void OS::Exit(int code) {
213 exit(code); 225 exit(code);
214 } 226 }
215 227
216 } // namespace dart 228 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698