MCPcopy Create free account
hub / github.com/F-Stack/f-stack / mallocAndLoadFile_orDie

Function mallocAndLoadFile_orDie

freebsd/contrib/zstd/examples/common.h:204–210  ·  view source on GitHub ↗

! 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. */

Source from the content-addressed store, hash-verified

202 * otherwise it will printout an error to stderr and exit.
203 */
204static 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 *

Callers 6

createDict_orDieFunction · 0.85
decompressFunction · 0.85
decompressFunction · 0.85
compress_orDieFunction · 0.85
createCDict_orDieFunction · 0.85
compressFunction · 0.85

Calls 3

fsize_orDieFunction · 0.85
malloc_orDieFunction · 0.85
loadFile_orDieFunction · 0.85

Tested by

no test coverage detected