| 40 | // file is of type |T|. |
| 41 | template <typename T> |
| 42 | void ReadFile(FILE* file, std::vector<T>* data) { |
| 43 | if (file == nullptr) return; |
| 44 | |
| 45 | const int buf_size = 4096 / sizeof(T); |
| 46 | T buf[buf_size]; |
| 47 | while (size_t len = fread(buf, sizeof(T), buf_size, file)) { |
| 48 | data->insert(data->end(), buf, buf + len); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | // Returns true if |file| has encountered an error opening the file or reading |
| 53 | // from it. If there was an error, writes an error message to standard error. |
no test coverage detected