| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 // Defined when linking against shared lib on Windows. | 6 // Defined when linking against shared lib on Windows. |
| 7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED) | 7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED) |
| 8 #define V8_SHARED | 8 #define V8_SHARED |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1106 return NULL; | 1106 return NULL; |
| 1107 #endif | 1107 #endif |
| 1108 } | 1108 } |
| 1109 | 1109 |
| 1110 | 1110 |
| 1111 static char* ReadChars(Isolate* isolate, const char* name, int* size_out) { | 1111 static char* ReadChars(Isolate* isolate, const char* name, int* size_out) { |
| 1112 FILE* file = FOpen(name, "rb"); | 1112 FILE* file = FOpen(name, "rb"); |
| 1113 if (file == NULL) return NULL; | 1113 if (file == NULL) return NULL; |
| 1114 | 1114 |
| 1115 fseek(file, 0, SEEK_END); | 1115 fseek(file, 0, SEEK_END); |
| 1116 int size = ftell(file); | 1116 size_t size = ftell(file); |
| 1117 rewind(file); | 1117 rewind(file); |
| 1118 | 1118 |
| 1119 char* chars = new char[size + 1]; | 1119 char* chars = new char[size + 1]; |
| 1120 chars[size] = '\0'; | 1120 chars[size] = '\0'; |
| 1121 for (int i = 0; i < size;) { | 1121 for (size_t i = 0; i < size;) { |
| 1122 int read = static_cast<int>(fread(&chars[i], 1, size - i, file)); | 1122 i += fread(&chars[i], 1, size - i, file); |
| 1123 i += read; | 1123 if (ferror(file)) { |
| 1124 fclose(file); |
| 1125 delete[] chars; |
| 1126 return nullptr; |
| 1127 } |
| 1124 } | 1128 } |
| 1125 fclose(file); | 1129 fclose(file); |
| 1126 *size_out = size; | 1130 *size_out = static_cast<int>(size); |
| 1127 return chars; | 1131 return chars; |
| 1128 } | 1132 } |
| 1129 | 1133 |
| 1130 | 1134 |
| 1131 struct DataAndPersistent { | 1135 struct DataAndPersistent { |
| 1132 uint8_t* data; | 1136 uint8_t* data; |
| 1133 int byte_length; | 1137 int byte_length; |
| 1134 Global<ArrayBuffer> handle; | 1138 Global<ArrayBuffer> handle; |
| 1135 }; | 1139 }; |
| 1136 | 1140 |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1728 } | 1732 } |
| 1729 | 1733 |
| 1730 } // namespace v8 | 1734 } // namespace v8 |
| 1731 | 1735 |
| 1732 | 1736 |
| 1733 #ifndef GOOGLE3 | 1737 #ifndef GOOGLE3 |
| 1734 int main(int argc, char* argv[]) { | 1738 int main(int argc, char* argv[]) { |
| 1735 return v8::Shell::Main(argc, argv); | 1739 return v8::Shell::Main(argc, argv); |
| 1736 } | 1740 } |
| 1737 #endif | 1741 #endif |
| OLD | NEW |