OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 if (fread(&size, sizeof(size), 1, file) != 1) | 23 if (fread(&size, sizeof(size), 1, file) != 1) |
24 return 0; | 24 return 0; |
25 if (size <= 0) | 25 if (size <= 0) |
26 return 0; | 26 return 0; |
27 | 27 |
28 bytes->reset(new uint8_t[size]); | 28 bytes->reset(new uint8_t[size]); |
29 return fread(bytes->get(), sizeof((*bytes)[0]), size, file); | 29 return fread(bytes->get(), sizeof((*bytes)[0]), size, file); |
30 } | 30 } |
31 | 31 |
32 // Returns true on success, false on error or end-of-file. | 32 // Returns true on success, false on error or end-of-file. |
33 bool ReadMessageFromFile(FILE* file, ::google::protobuf::MessageLite* msg) { | 33 bool ReadMessageFromFile(FILE* file, MessageLite* msg) { |
34 std::unique_ptr<uint8_t[]> bytes; | 34 std::unique_ptr<uint8_t[]> bytes; |
35 size_t size = ReadMessageBytesFromFile(file, &bytes); | 35 size_t size = ReadMessageBytesFromFile(file, &bytes); |
36 if (!size) | 36 if (!size) |
37 return false; | 37 return false; |
38 | 38 |
39 msg->Clear(); | 39 msg->Clear(); |
40 return msg->ParseFromArray(bytes.get(), size); | 40 return msg->ParseFromArray(bytes.get(), size); |
41 } | 41 } |
42 | 42 |
43 } // namespace webrtc | 43 } // namespace webrtc |
OLD | NEW |