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

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 #ifndef va_copy
Ivan Posva 2012/04/17 18:54:44 The only question I have is whether we should move
siva 2012/04/17 23:55:00 Will move it once we run into that issue again. Fo
164 #define va_copy(dst, src) (memmove(&(dst), &(src), sizeof(dst)))
165 #endif /* va_copy */
166
167
163 int OS::VSNPrint(char* str, size_t size, const char* format, va_list args) { 168 int OS::VSNPrint(char* str, size_t size, const char* format, va_list args) {
164 if (str == NULL || size == 0) { 169 if (str == NULL || size == 0) {
165 return _vscprintf(format, args); 170 return _vscprintf(format, args);
166 } 171 }
167 int written =_vsnprintf(str, size, format, args); 172 va_list args_copy;
173 va_copy(args_copy, args);
174 int written =_vsnprintf(str, size, format, args_copy);
175 va_end(args_copy);
168 if (written < 0) { 176 if (written < 0) {
169 // _vsnprintf returns -1 if the number of characters to be written is 177 // _vsnprintf returns -1 if the number of characters to be written is
170 // larger than 'size', so we call _vscprintf which returns the number 178 // larger than 'size', so we call _vscprintf which returns the number
171 // of characters that would have been written. 179 // of characters that would have been written.
172 written = _vscprintf(format, args); 180 va_list args_retry;
181 va_copy(args_retry, args);
182 written = _vscprintf(format, args_retry);
183 va_end(args_retry);
173 } 184 }
174 // Make sure to zero-terminate the string if the output was 185 // Make sure to zero-terminate the string if the output was
175 // truncated or if there was an error. 186 // truncated or if there was an error.
176 if (written >= size) { 187 if (written >= size) {
177 str[size - 1] = '\0'; 188 str[size - 1] = '\0';
178 } 189 }
179 return written; 190 return written;
180 } 191 }
181 192
182 193
(...skipping 24 matching lines...) Expand all
207 void OS::Abort() { 218 void OS::Abort() {
208 abort(); 219 abort();
209 } 220 }
210 221
211 222
212 void OS::Exit(int code) { 223 void OS::Exit(int code) {
213 exit(code); 224 exit(code);
214 } 225 }
215 226
216 } // namespace dart 227 } // 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