! mallocAndLoadFile_orDie() : * allocate memory buffer and then load file into it. * * Note: This function will send an error to stderr and exit if memory allocation * fails or it cannot read data from the given file path. * * @return If successful this function will return buffer and bufferSize(=fileSize), * otherwise it will printout an error to stderr and exit. */
| 202 | * otherwise it will printout an error to stderr and exit. |
| 203 | */ |
| 204 | static void* mallocAndLoadFile_orDie(const char* fileName, size_t* bufferSize) { |
| 205 | size_t const fileSize = fsize_orDie(fileName); |
| 206 | *bufferSize = fileSize; |
| 207 | void* const buffer = malloc_orDie(*bufferSize); |
| 208 | loadFile_orDie(fileName, buffer, *bufferSize); |
| 209 | return buffer; |
| 210 | } |
| 211 | |
| 212 | /*! saveFile_orDie() : |
| 213 | * |
no test coverage detected