OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 #include "src/startup-data-util.h" | 5 #include "src/startup-data-util.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include "src/base/logging.h" | 10 #include "src/base/logging.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 delete[] natives_.data; | 37 delete[] natives_.data; |
38 delete[] snapshot_.data; | 38 delete[] snapshot_.data; |
39 } | 39 } |
40 | 40 |
41 | 41 |
42 char* StartupDataHandler::RelativePath(char** buffer, const char* exec_path, | 42 char* StartupDataHandler::RelativePath(char** buffer, const char* exec_path, |
43 const char* name) { | 43 const char* name) { |
44 DCHECK(exec_path); | 44 DCHECK(exec_path); |
45 const char* last_slash = strrchr(exec_path, '/'); | 45 const char* last_slash = strrchr(exec_path, '/'); |
46 if (last_slash) { | 46 if (last_slash) { |
47 int after_slash = last_slash - exec_path + 1; | 47 int after_slash = static_cast<int>(last_slash - exec_path + 1); |
48 int name_length = static_cast<int>(strlen(name)); | 48 int name_length = static_cast<int>(strlen(name)); |
49 *buffer = reinterpret_cast<char*>(calloc(after_slash + name_length + 1, 1)); | 49 *buffer = reinterpret_cast<char*>(calloc(after_slash + name_length + 1, 1)); |
50 strncpy(*buffer, exec_path, after_slash); | 50 strncpy(*buffer, exec_path, after_slash); |
51 strncat(*buffer, name, name_length); | 51 strncat(*buffer, name, name_length); |
52 } else { | 52 } else { |
53 *buffer = strdup(name); | 53 *buffer = strdup(name); |
54 } | 54 } |
55 return *buffer; | 55 return *buffer; |
56 } | 56 } |
57 | 57 |
(...skipping 10 matching lines...) Expand all Loading... |
68 void (*setter_fn)(v8::StartupData*)) { | 68 void (*setter_fn)(v8::StartupData*)) { |
69 startup_data->data = NULL; | 69 startup_data->data = NULL; |
70 startup_data->raw_size = 0; | 70 startup_data->raw_size = 0; |
71 | 71 |
72 if (!blob_file) return; | 72 if (!blob_file) return; |
73 | 73 |
74 FILE* file = fopen(blob_file, "rb"); | 74 FILE* file = fopen(blob_file, "rb"); |
75 if (!file) return; | 75 if (!file) return; |
76 | 76 |
77 fseek(file, 0, SEEK_END); | 77 fseek(file, 0, SEEK_END); |
78 startup_data->raw_size = ftell(file); | 78 startup_data->raw_size = static_cast<int>(ftell(file)); |
79 rewind(file); | 79 rewind(file); |
80 | 80 |
81 startup_data->data = new char[startup_data->raw_size]; | 81 startup_data->data = new char[startup_data->raw_size]; |
82 int read_size = static_cast<int>(fread(const_cast<char*>(startup_data->data), | 82 int read_size = static_cast<int>(fread(const_cast<char*>(startup_data->data), |
83 1, startup_data->raw_size, file)); | 83 1, startup_data->raw_size, file)); |
84 fclose(file); | 84 fclose(file); |
85 | 85 |
86 if (startup_data->raw_size == read_size) (*setter_fn)(startup_data); | 86 if (startup_data->raw_size == read_size) (*setter_fn)(startup_data); |
87 } | 87 } |
88 | 88 |
89 #endif // V8_USE_EXTERNAL_STARTUP_DATA | 89 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
90 | 90 |
91 } // namespace v8 | 91 } // namespace v8 |
OLD | NEW |