------------------------------------------------------------------------- RecFileImport_Xmalloc -------------------------------------------------------------------------
| 56 | // RecFileImport_Xmalloc |
| 57 | //------------------------------------------------------------------------- |
| 58 | static int |
| 59 | RecFileImport_Xmalloc(const char *file, char **file_buf, int *file_size) |
| 60 | { |
| 61 | int err = REC_ERR_FAIL; |
| 62 | RecHandle h_file; |
| 63 | int bytes_read; |
| 64 | |
| 65 | if (file && file_buf && file_size) { |
| 66 | *file_buf = nullptr; |
| 67 | *file_size = 0; |
| 68 | if ((h_file = RecFileOpenR(file)) != REC_HANDLE_INVALID) { |
| 69 | *file_size = RecFileGetSize(h_file); |
| 70 | *file_buf = static_cast<char *>(ats_malloc(*file_size + 1)); |
| 71 | if (RecFileRead(h_file, *file_buf, *file_size, &bytes_read) != REC_ERR_FAIL && bytes_read == *file_size) { |
| 72 | (*file_buf)[*file_size] = '\0'; |
| 73 | err = REC_ERR_OKAY; |
| 74 | } else { |
| 75 | ats_free(*file_buf); |
| 76 | *file_buf = nullptr; |
| 77 | *file_size = 0; |
| 78 | } |
| 79 | RecFileClose(h_file); |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | return err; |
| 84 | } |
| 85 | |
| 86 | //------------------------------------------------------------------------- |
| 87 | // RecConfigOverrideFromRunroot |
no test coverage detected