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

Side by Side Diff: src/utils.cc

Issue 18583: Change type of snapshot from char array to byte array to avoid portability pr... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 11 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 | « src/utils.h ('k') | 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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 DeleteArray(result); 175 DeleteArray(result);
176 return NULL; 176 return NULL;
177 } 177 }
178 i += read; 178 i += read;
179 } 179 }
180 fclose(file); 180 fclose(file);
181 return result; 181 return result;
182 } 182 }
183 183
184 184
185 char* ReadChars(const char* filename, int* size, bool verbose) { 185 byte* ReadBytes(const char* filename, int* size, bool verbose) {
186 return ReadCharsFromFile(filename, size, 0, verbose); 186 char* chars = ReadCharsFromFile(filename, size, 0, verbose);
187 return reinterpret_cast<byte*>(chars);
187 } 188 }
188 189
189 190
190 Vector<const char> ReadFile(const char* filename, 191 Vector<const char> ReadFile(const char* filename,
191 bool* exists, 192 bool* exists,
192 bool verbose) { 193 bool verbose) {
193 int size; 194 int size;
194 char* result = ReadCharsFromFile(filename, &size, 1, verbose); 195 char* result = ReadCharsFromFile(filename, &size, 1, verbose);
195 if (!result) { 196 if (!result) {
196 *exists = false; 197 *exists = false;
(...skipping 29 matching lines...) Expand all
226 OS::PrintError("Cannot open file %s for reading.\n", filename); 227 OS::PrintError("Cannot open file %s for reading.\n", filename);
227 } 228 }
228 return 0; 229 return 0;
229 } 230 }
230 int written = WriteCharsToFile(str, size, f); 231 int written = WriteCharsToFile(str, size, f);
231 fclose(f); 232 fclose(f);
232 return written; 233 return written;
233 } 234 }
234 235
235 236
237 int WriteBytes(const char* filename,
238 const byte* bytes,
239 int size,
240 bool verbose) {
241 const char* str = reinterpret_cast<const char*>(bytes);
242 return WriteChars(filename, str, size, verbose);
243 }
244
245
236 StringBuilder::StringBuilder(int size) { 246 StringBuilder::StringBuilder(int size) {
237 buffer_ = Vector<char>::New(size); 247 buffer_ = Vector<char>::New(size);
238 position_ = 0; 248 position_ = 0;
239 } 249 }
240 250
241 251
242 void StringBuilder::AddString(const char* s) { 252 void StringBuilder::AddString(const char* s) {
243 AddSubstring(s, strlen(s)); 253 AddSubstring(s, strlen(s));
244 } 254 }
245 255
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 buffer_[position_] = '\0'; 288 buffer_[position_] = '\0';
279 // Make sure nobody managed to add a 0-character to the 289 // Make sure nobody managed to add a 0-character to the
280 // buffer while building the string. 290 // buffer while building the string.
281 ASSERT(strlen(buffer_.start()) == static_cast<size_t>(position_)); 291 ASSERT(strlen(buffer_.start()) == static_cast<size_t>(position_));
282 position_ = -1; 292 position_ = -1;
283 ASSERT(is_finalized()); 293 ASSERT(is_finalized());
284 return buffer_.start(); 294 return buffer_.start();
285 } 295 }
286 296
287 } } // namespace v8::internal 297 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698